Add support for extracting sources from eggs.
This commit is contained in:
@@ -61,9 +61,9 @@ def find_source(module):
|
|||||||
Args:
|
Args:
|
||||||
module: str, Name of the module.
|
module: str, Name of the module.
|
||||||
Returns:
|
Returns:
|
||||||
A tuple of (isdir, location), a boolean indicating if it
|
A tuple of (isdir, location), a boolean that's True if
|
||||||
is a directory (True) or a single file module (False), and
|
the source is a directory, False is it's a file,
|
||||||
the absolute path of the source.
|
and the absolute path of the source.
|
||||||
"""
|
"""
|
||||||
isdir = False
|
isdir = False
|
||||||
location = ''
|
location = ''
|
||||||
@@ -74,7 +74,12 @@ def find_source(module):
|
|||||||
isdir = True
|
isdir = True
|
||||||
location = os.path.dirname(m.__file__)
|
location = os.path.dirname(m.__file__)
|
||||||
else:
|
else:
|
||||||
|
if os.path.isfile(m.__file__):
|
||||||
location = m.__file__.rsplit('.', 1)[0] + '.py'
|
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)
|
return (isdir, location)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user