Anonymous avatar Anonymous committed f5e9303

[svn r21851] Make installing editable from already-existing source work

Comments (0)

Files changed (2)

 * Detect zip files, even when the file doesn't have a ``.zip``
   extension and it is served with the wrong Content-Type.
 
+* Installing editable from existing source now works, like ``pip
+  install -e some/path/`` will install the package in ``some/path/``.
+  Most importantly, anything that package requires will also be
+  installed by pip.
+
 0.2.1
 -----
 
     @classmethod
     def from_editable(cls, editable_req, comes_from=None):
         name, url = parse_editable(editable_req)
-        return cls(name, comes_from, editable=True, url=url)
+        if url.startswith('file:'):
+            source_dir = url_to_filename(url)
+        else:
+            source_dir = None
+        return cls(name, comes_from, source_dir=source_dir, editable=True, url=url)
 
     @classmethod
     def from_line(cls, name, comes_from=None):
     def correct_build_location(self):
         """If the build location was a temporary directory, this will move it
         to a new more permanent location"""
+        if self.source_dir is not None:
+            return
         assert self.req is not None
         assert self._temp_build_dir
         old_location = self._temp_build_dir
             return
         assert self.editable
         assert self.source_dir
+        if self.url.startswith('file:'):
+            # Static paths don't get updated
+            return
         assert '+' in self.url, "bad url: %r" % self.url
         if not self.update:
             return
             is_bundle = False
             try:
                 if req_to_install.editable:
-                    location = req_to_install.build_location(self.src_dir)
-                    req_to_install.source_dir = location
+                    if req_to_install.source_dir is None:
+                        location = req_to_install.build_location(self.src_dir)
+                        req_to_install.source_dir = location
+                    else:
+                        location = req_to_install.source_dir
                     req_to_install.update_editable()
                     req_to_install.run_egg_info()
                 elif install:
     """Parses svn+http://blahblah@rev#egg=Foobar into a requirement
     (Foobar) and a URL"""
     url = editable_req
+    if os.path.isdir(url) and os.path.exists(os.path.join(url, 'setup.py')):
+        # Treating it as code that has already been checked out
+        url = filename_to_url(url)
+    if url.lower().startswith('file:'):
+        return None, url
     if url.lower().startswith('svn:'):
         url = 'svn+' + url
     if '+' not in url:
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.