ianb  committed f5e9303

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

  • Participants
  • Parent commits 751f6af

Comments (0)

Files changed (2)

File docs/news.txt

 * 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.
     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)
     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
         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:
             is_bundle = False
                 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
                 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, '')):
+        # 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: