From c1b3e6333389d6c3cd7e18f20951b8c18dfdffdc Mon Sep 17 00:00:00 2001 From: Laurie O Date: Mon, 22 May 2023 23:37:14 +1000 Subject: [PATCH] Don't provide dist-info-metadata attribute Fixes issue when pip tries to get unprovided metadata --- src/proxpi/_cache.py | 9 ++++++++- tests/test_integration.py | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/proxpi/_cache.py b/src/proxpi/_cache.py index 96e80f1..03c4831 100644 --- a/src/proxpi/_cache.py +++ b/src/proxpi/_cache.py @@ -228,7 +228,14 @@ def _list_files(self, package_name: str): if child.tag == "a": name = child.text url = urllib.parse.urljoin(response.request.url, child.attrib["href"]) - attributes = {k: v for k, v in child.attrib.items() if k != "href"} + attributes = { + k: v + for k, v in child.attrib.items() + # Specifically ignore dist-info-metadat attribute: this version of + # proxpi doesn't support serving the file. See GitHub issue + # EpicWink/proxpi#23 + if k not in ("href", "data-dist-info-metadata") + } fragment = urllib.parse.urlsplit(url).fragment package.files[name] = File(name, url, fragment, attributes) self._packages[package_name] = package diff --git a/tests/test_integration.py b/tests/test_integration.py index 5097811..469a64b 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -48,6 +48,7 @@ def test_pip_download(server, tmp_path): "download", "--index-url", "http://127.0.0.1:5042/index/", + "--no-deps", ] p = subprocess.run( [*args, "--dest", str(tmp_path / "dest1"), "Jinja2", "marshmallow"] @@ -62,6 +63,9 @@ def test_pip_download(server, tmp_path): contents = list((tmp_path / "dest2").iterdir()) print(contents) assert any("jinja2" in p.name.lower() for p in contents) + subprocess.run( + [*args, "--dest", str(tmp_path / "dest3"), "sphinx == 7.0.1"], check=True + ) def test_list(server):