Add support for extracting sources from eggs.
diff --git a/bin/enable-app-engine-project b/bin/enable-app-engine-project
index 8a53ec2..b67cde8 100755
--- a/bin/enable-app-engine-project
+++ b/bin/enable-app-engine-project
@@ -61,9 +61,9 @@
Args:
module: str, Name of the module.
Returns:
- A tuple of (isdir, location), a boolean indicating if it
- is a directory (True) or a single file module (False), and
- the absolute path of the source.
+ A tuple of (isdir, location), a boolean that's True if
+ the source is a directory, False is it's a file,
+ and the absolute path of the source.
"""
isdir = False
location = ''
@@ -74,7 +74,12 @@
isdir = True
location = os.path.dirname(m.__file__)
else:
- location = m.__file__.rsplit('.', 1)[0] + '.py'
+ if os.path.isfile(m.__file__):
+ location = m.__file__.rsplit('.', 1)[0] + '.py'
+ else:
+ # The file is an egg, extract to a temporary location
+ import pkg_resources
+ location = pkg_resources.resource_filename(module, module + '.py')
return (isdir, location)