← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~ines-almeida/launchpad:bam-description-not-none into launchpad:master

 

Ines Almeida has proposed merging ~ines-almeida/launchpad:bam-description-not-none into launchpad:master.

Commit message:
Allow binary package release wheel without description
    
The previous version of the `pkginfo` library we used would set the description field to an empty string if none was found. The current version sets it to None which lead to a DB exception. This change mimics the behavior of the previous version of the `pkginfo` library by setting the description of a binary package release to an empty string if none is found
    
LP:#2075530

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/470785

Another solution would be to update the DB restriction, but given we already do such a similar thing of `summary=wheel.summary or ""` in 2 other fields, it seems coherent to do the same in this one.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~ines-almeida/launchpad:bam-description-not-none into launchpad:master.
diff --git a/lib/lp/soyuz/model/archivejob.py b/lib/lp/soyuz/model/archivejob.py
index b3beedf..4aeb4c8 100644
--- a/lib/lp/soyuz/model/archivejob.py
+++ b/lib/lp/soyuz/model/archivejob.py
@@ -442,7 +442,7 @@ class CIBuildUploadJob(ArchiveJobDerived):
                 name=wheel.name,
                 version=wheel.version,
                 summary=wheel.summary or "",
-                description=wheel.description,
+                description=wheel.description or "",
                 architecturespecific="any" not in parsed_path.platform_tags,
                 homepage=wheel.home_page or "",
             )
diff --git a/lib/lp/soyuz/tests/data/wheel-no-description/README.md b/lib/lp/soyuz/tests/data/wheel-no-description/README.md
new file mode 100644
index 0000000..3135dc3
--- /dev/null
+++ b/lib/lp/soyuz/tests/data/wheel-no-description/README.md
@@ -0,0 +1 @@
+An example package.  Build a wheel from this with `pyproject-build`.
diff --git a/lib/lp/soyuz/tests/data/wheel-no-description/dist/wheel_no_description-0.0.1-py3-none-any.whl b/lib/lp/soyuz/tests/data/wheel-no-description/dist/wheel_no_description-0.0.1-py3-none-any.whl
new file mode 100644
index 0000000..7f3ece4
Binary files /dev/null and b/lib/lp/soyuz/tests/data/wheel-no-description/dist/wheel_no_description-0.0.1-py3-none-any.whl differ
diff --git a/lib/lp/soyuz/tests/data/wheel-no-description/dist/wheel_no_description-0.0.1.tar.gz b/lib/lp/soyuz/tests/data/wheel-no-description/dist/wheel_no_description-0.0.1.tar.gz
new file mode 100644
index 0000000..8e0a594
Binary files /dev/null and b/lib/lp/soyuz/tests/data/wheel-no-description/dist/wheel_no_description-0.0.1.tar.gz differ
diff --git a/lib/lp/soyuz/tests/data/wheel-no-description/pyproject.toml b/lib/lp/soyuz/tests/data/wheel-no-description/pyproject.toml
new file mode 100644
index 0000000..b0f0765
--- /dev/null
+++ b/lib/lp/soyuz/tests/data/wheel-no-description/pyproject.toml
@@ -0,0 +1,3 @@
+[build-system]
+requires = ["setuptools>=42"]
+build-backend = "setuptools.build_meta"
diff --git a/lib/lp/soyuz/tests/data/wheel-no-description/setup.cfg b/lib/lp/soyuz/tests/data/wheel-no-description/setup.cfg
new file mode 100644
index 0000000..b103bfd
--- /dev/null
+++ b/lib/lp/soyuz/tests/data/wheel-no-description/setup.cfg
@@ -0,0 +1,3 @@
+[metadata]
+name = wheel-no-description
+version = 0.0.1
diff --git a/lib/lp/soyuz/tests/test_archivejob.py b/lib/lp/soyuz/tests/test_archivejob.py
index 3244e4d..d961c3a 100644
--- a/lib/lp/soyuz/tests/test_archivejob.py
+++ b/lib/lp/soyuz/tests/test_archivejob.py
@@ -337,6 +337,48 @@ class TestCIBuildUploadJob(TestCaseWithFactory):
             ),
         )
 
+    def test__scanFiles_wheel_no_description(self):
+        """Ensure scanning a wheel without a description produces metadata with
+        empty string instead of None"""
+        archive = self.factory.makeArchive()
+        distroseries = self.factory.makeDistroSeries(
+            distribution=archive.distribution
+        )
+        build = self.makeCIBuild(archive.distribution)
+        report = self.factory.makeRevisionStatusReport(ci_build=build)
+        job = CIBuildUploadJob.create(
+            build,
+            build.git_repository.owner,
+            archive,
+            distroseries,
+            PackagePublishingPocket.RELEASE,
+            target_channel="edge",
+        )
+        path = Path(
+            "wheel-no-description/dist/"
+            "wheel_no_description-0.0.1-py3-none-any.whl"
+        )
+        tmpdir = Path(self.useFixture(TempDir()).path)
+        shutil.copy2(datadir(str(path)), str(tmpdir))
+        all_metadata = job._scanFiles(report, tmpdir)
+
+        self.assertThat(
+            all_metadata,
+            MatchesDict(
+                {
+                    path.name: MatchesStructure(
+                        format=Equals(BinaryPackageFormat.WHL),
+                        name=Equals("wheel-no-description"),
+                        version=Equals("0.0.1"),
+                        summary=Equals(""),
+                        description=Equals(""),
+                        architecturespecific=Is(False),
+                        homepage=Equals(""),
+                    ),
+                }
+            ),
+        )
+
     def test__scanFiles_sdist(self):
         archive = self.factory.makeArchive()
         distroseries = self.factory.makeDistroSeries(