Daniel Holth avatar Daniel Holth committed 99e183b

fix #42 (requiring packages with extras)

Comments (0)

Files changed (1)

wheel/bdist_wheel.py

     # Python < 2.7
     import distutils.sysconfig as sysconfig
 
-try:
-    import pkg_resources
-except ImportError:
-    # this dance makes the unit tests happy
-    # bdist_wheel won't really work without distribute
-    from wheel import pkg_resources
-    
+import pkg_resources
+
 safe_name = pkg_resources.safe_name
 safe_version = pkg_resources.safe_version
 
         return path
 
     def _to_requires_dist(self, requirement):
+        """Compose the version predicates for requirement in PEP 345 fashion."""
         requires_dist = []
         for op, ver in requirement.specs:
             # PEP 345 specifies but does not use == as part of a version spec
                 for req in reqs:
                     parsed_requirement = pkg_resources.Requirement.parse(req)
                     spec = self._to_requires_dist(parsed_requirement)
-                    pkg_info['Requires-Dist'] = parsed_requirement.key + \
-                        spec + condition
+                    extras = ",".join(parsed_requirement.extras)
+                    if extras:
+                        extras = "[%s]" % extras 
+                    pkg_info['Requires-Dist'] = (parsed_requirement.project_name 
+                                                 + extras 
+                                                 + spec 
+                                                 + condition)
         description = pkg_info['Description']
         if description:
             del pkg_info['Description']
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.