From 1fa5fe3287f76cf4109e452a6b915aff69e9e899 Mon Sep 17 00:00:00 2001 From: Jitka Halova Date: Thu, 6 Aug 2026 15:08:28 +0200 Subject: [PATCH] Add Core Metadata 2.5 upload support closes #1321 --- CHANGES/1321.feature | 1 + pulp_python/app/utils.py | 2 +- .../functional/api/test_crud_content_unit.py | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 CHANGES/1321.feature diff --git a/CHANGES/1321.feature b/CHANGES/1321.feature new file mode 100644 index 00000000..b5096ebc --- /dev/null +++ b/CHANGES/1321.feature @@ -0,0 +1 @@ +Added support for uploading packages with Core Metadata 2.5 via twine. diff --git a/pulp_python/app/utils.py b/pulp_python/app/utils.py index 57e78b3b..f1da8dd0 100644 --- a/pulp_python/app/utils.py +++ b/pulp_python/app/utils.py @@ -30,7 +30,7 @@ PYPI_LAST_SERIAL = "X-PYPI-LAST-SERIAL" """TODO This serial constant is temporary until Python repositories implements serials""" PYPI_SERIAL_CONSTANT = 1000000000 -SUPPORTED_METADATA_VERSIONS = ("1.0", "1.1", "1.2", "2.0", "2.1", "2.2", "2.3", "2.4") +SUPPORTED_METADATA_VERSIONS = ("1.0", "1.1", "1.2", "2.0", "2.1", "2.2", "2.3", "2.4", "2.5") SIMPLE_API_VERSION = "1.1" PYPI_SIMPLE_V1_HTML = "application/vnd.pypi.simple.v1+html" diff --git a/pulp_python/tests/functional/api/test_crud_content_unit.py b/pulp_python/tests/functional/api/test_crud_content_unit.py index 3641803a..f70abf85 100644 --- a/pulp_python/tests/functional/api/test_crud_content_unit.py +++ b/pulp_python/tests/functional/api/test_crud_content_unit.py @@ -1,6 +1,7 @@ from urllib.parse import urljoin import pytest +import requests from pypi_simple import PyPISimple from pulpcore.tests.functional.utils import PulpTaskError @@ -182,6 +183,24 @@ def test_upload_metadata_24_spec(python_content_factory): assert content.license_file == '["LICENSE"]' +@pytest.mark.parallel +def test_legacy_upload_metadata_25(python_empty_repo_distro, python_package_dist_directory): + """Test that metadata_version 2.5 (PEP 794) is accepted via the legacy upload endpoint.""" + flit_url = get_package_url("flit", "flit-4.0.2-py3-none-any.whl") + _, flit_file = python_package_dist_directory(flit_url) + _, distro = python_empty_repo_distro() + url = urljoin(distro.base_url, "legacy/") + sha256 = "7b0b0038cd91a7f04e2e287d958dc5f25e68ffeed0b93e613bd50aec99a0d9ca" + with open(flit_file, "rb") as f: + response = requests.post( + url, + data={"sha256_digest": sha256, "metadata_version": "2.5"}, + files={"content": f}, + auth=("admin", "password"), + ) + assert response.status_code == 202 + + @pytest.mark.parallel def test_package_creation_with_metadata( pulp_content_url,