Commits

Lennart Regebro committed 5a005db

Added a test to make sure a package has an sdist on PyPI.

Comments (0)

Files changed (3)

 1.4 (unreleased)
 ----------------
 
-- Nothing changed yet.
+- Issue #13: Pyroma would fail when checking a package name if no source
+  distribution could be found.
 
 
 1.3.1 (2013-05-29)

pyroma/pypidata.py

     # If there is a source download, download it, and get that data.
     # This is done mostly to do the imports check.
     data['_source_download'] = False
+    data['_setuptools'] = None # Mark it as unknown, in case no sdist is found.
+    data['_has_sdist'] = False
+    
     for download in urls:
         if download['packagetype'] == 'sdist':
             # Found a source distribution. Download and analyze it.
+            data['_has_sdist'] = True
             tempdir = tempfile.gettempdir()
             filename = download['url'].split('/')[-1]
             tmp = os.path.join(tempdir, filename)

pyroma/ratings.py

         return "Setuptools and Distribute support running tests. By "\
                "specifying a test suite, it's easy to find and run tests "\
                "both for automated tools and humans."
+
+class SDist(BaseTest):
+    weight = 100
+    
+    def test(self, data):
+        if not '_has_sdist' in data:
+            # We aren't checking on PyPI
+            weight = 0
+            return None
+        return data['_has_sdist']
+
+    def message(self):
+        return "You have no source distribution on the Cheeseshop. Uploading "\
+        "the source distribution to the Cheeseshop ensures maximum "\
+        "availability of your package."
     
 class PackageDocs(BaseTest):
     weight = 0 # Just a recommendation
     License(),
     ZipSafe(),
     TestSuite(),
+    SDist(),
     PackageDocs(),
     ValidREST(),
     BusFactor(),