Ian Bicking avatar Ian Bicking committed f3be2ee Merge

Fix _find_package_path to work with nspath packages, add get_env() function

Comments (0)

Files changed (1)


         shutil.rmtree(self.root_path, ignore_errors=True)
     def _find_package_path(self, module):
-        return os.path.dirname(os.path.dirname(__import__(module).__file__))
+        __import__(module)
+        mod = sys.modules[module]
+        if not hasattr(mod, '__file__'):
+            raise AttributeError('Module %r has no __file__, cannot determine path' % mod)
+        location = os.path.dirname(os.path.abspath(mod.__file__))
+        if '.' in module:
+            location = os.path.dirname(location)
+        return os.path.dirname(location)
     def _use_cached_pypi_server(self):
         site_packages = self.root_path / self.site_packages
     return env.run('pip', *args, **kw)
+def get_env():
+    return env
 def write_file(filename, text, dest=None):
     """Write a file in the dest (default=env.scratch_path)
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.