← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~jugmac00/launchpad:upgrade-wheel-filename into launchpad:master

 

Jürgen Gmach has proposed merging ~jugmac00/launchpad:upgrade-wheel-filename into launchpad:master.

Commit message:
Remove dependency on wheel-filename

The same functionality is provided by the `packaging` dependency, which
we use anyway, and which is maintained by a number of cpython core devs,
whereas the previously used `wheel-filename` is only maintained by one
single maintainer, who refused to release a new package which supports
newer Python versions to PyPI.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jugmac00/launchpad/+git/launchpad/+merge/477837
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~jugmac00/launchpad:upgrade-wheel-filename into launchpad:master.
diff --git a/lib/lp/soyuz/model/archivejob.py b/lib/lp/soyuz/model/archivejob.py
index 100e3ba..ee23fee 100644
--- a/lib/lp/soyuz/model/archivejob.py
+++ b/lib/lp/soyuz/model/archivejob.py
@@ -5,6 +5,7 @@ import io
 import json
 import logging
 import os
+import os.path
 import tarfile
 import tempfile
 import zipfile
@@ -14,10 +15,10 @@ from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, Union
 
 import zstandard
 from lazr.delegates import delegate_to
+from packaging.utils import parse_wheel_filename
 from pkginfo import SDist, Wheel
 from storm.expr import And
 from storm.locals import JSON, Int, Reference
-from wheel_filename import parse_wheel_filename
 from zope.component import getUtility
 from zope.interface import implementer, provider
 from zope.security.proxy import removeSecurityProxy
@@ -431,10 +432,12 @@ class CIBuildUploadJob(ArchiveJobDerived):
     ) -> Dict[str, ArtifactMetadata]:
         all_metadata = {}
         for path in paths:
-            if not path.name.endswith(".whl"):
+            filename = str(os.path.basename(os.fsdecode(path)))
+            if not filename.endswith(".whl"):
                 continue
             try:
-                parsed_path = parse_wheel_filename(str(path))
+                _, _, _, tags = parse_wheel_filename(str(filename))
+                platforms = [tag.platform for tag in set(tags)]
                 wheel = Wheel(str(path))
             except Exception as e:
                 logger.warning(
@@ -448,7 +451,7 @@ class CIBuildUploadJob(ArchiveJobDerived):
                 version=wheel.version,
                 summary=wheel.summary or "",
                 description=wheel.description or "",
-                architecturespecific="any" not in parsed_path.platform_tags,
+                architecturespecific="any" not in platforms,  # != platform,
                 homepage=wheel.home_page or "",
             )
         return all_metadata
diff --git a/lib/lp/soyuz/tests/test_archivejob.py b/lib/lp/soyuz/tests/test_archivejob.py
index b006a5f..d4c5488 100644
--- a/lib/lp/soyuz/tests/test_archivejob.py
+++ b/lib/lp/soyuz/tests/test_archivejob.py
@@ -1895,7 +1895,7 @@ class TestCIBuildUploadJob(TestCaseWithFactory):
         expected_logs = [
             "Running %r (ID %d) in status Waiting" % (job, job.job_id),
             "Failed to scan _invalid.whl as a Python wheel: Invalid wheel "
-            "filename: '_invalid.whl'",
+            "filename (wrong number of parts): '_invalid'",
             "%r (ID %d) failed with user error %r."
             % (
                 job,
diff --git a/requirements/launchpad.txt b/requirements/launchpad.txt
index f7d44a8..30598c9 100644
--- a/requirements/launchpad.txt
+++ b/requirements/launchpad.txt
@@ -192,7 +192,6 @@ webencodings==0.5.1
 WebOb==1.8.9
 WebTest==2.0.35
 Werkzeug==1.0.1
-wheel-filename==1.1.0
 wrapt==1.12.1
 wsgi-intercept==1.9.2
 WSGIProxy2==0.4.6