Add support for extracting sources from eggs.

This commit is contained in:
Joe Gregorio
2011-05-22 23:21:54 -04:00
parent 432f17ec61
commit be927fbe43

View File

@@ -61,9 +61,9 @@ def find_source(module):
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 @@ def find_source(module):
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)