Armin Ronacher avatar Armin Ronacher committed c1507ec

Make install --editable work for multiple matches of .egg-info

In case it finds more than one, it will pick the toplevel one. This fixes
problems caused when for example someone extracts a tarball in a dist
folder for testing purposes.

Comments (0)

Files changed (1)

                     filenames.extend([os.path.join(root, dir)
                                      for dir in dirs])
                 filenames = [f for f in filenames if f.endswith('.egg-info')]
+            if not filenames:
+                raise InstallationError('No files/directores in %s (from %s)' % (base, filename))
             assert filenames, "No files/directories in %s (from %s)" % (base, filename)
-            assert len(filenames) == 1, "Unexpected files/directories in %s: %s" % (base, ' '.join(filenames))
+            # if we have more than one match, we pick the toplevel one.  This can
+            # easily be the case if there is a dist folder which contains an
+            # extracted tarball for testing purposes.
+            if len(filenames) > 1:
+                filenames.sort(key=lambda x: x.count(os.path.sep) +
+                                             (os.path.altsep and
+                                              x.count(os.path.altsep) or 0))
             self._egg_info_path = os.path.join(base, filenames[0])
         return os.path.join(self._egg_info_path, filename)
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
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.