diff options
author | Pearu Peterson <pearu.peterson@gmail.com> | 2006-02-09 12:50:30 +0000 |
---|---|---|
committer | Pearu Peterson <pearu.peterson@gmail.com> | 2006-02-09 12:50:30 +0000 |
commit | 44f0e40eed3cc04292f1295ae524a1d5aedb382c (patch) | |
tree | 13b825c68acae55f7908d8e59a431b1c04362439 /numpy/distutils/misc_util.py | |
parent | 2eb3a4b6e293a96465229ce18109b2ccae97ca70 (diff) | |
download | numpy-44f0e40eed3cc04292f1295ae524a1d5aedb382c.tar.gz |
Fixed get_path bug fix.
Diffstat (limited to 'numpy/distutils/misc_util.py')
-rw-r--r-- | numpy/distutils/misc_util.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py index 0e71add8a..8855ccc84 100644 --- a/numpy/distutils/misc_util.py +++ b/numpy/distutils/misc_util.py @@ -27,18 +27,21 @@ def get_path(mod_name, parent_path=None): Returned path is relative to parent_path when given, otherwise it is absolute path. """ - if mod_name == '__main__' and not hasattr('__main__', '__file__'): - # we're probably running setup.py as execfile("setup.py") - # (likely we're building an egg) - d = os.path.abspath('.') - elif mod_name == '__builtin__': + if mod_name == '__builtin__': #builtin if/then added by Pearu for use in core.run_setup. d = os.path.dirname(os.path.abspath(sys.argv[0])) else: __import__(mod_name) mod = sys.modules[mod_name] - filename = mod.__file__ - d = os.path.dirname(os.path.abspath(filename)) + if hasattr(mod,'__file__'): + filename = mod.__file__ + d = os.path.dirname(os.path.abspath(mod.__file__)) + else: + # we're probably running setup.py as execfile("setup.py") + # (likely we're building an egg) + d = os.path.abspath('.') + # hmm, should we use sys.argv[0] like in __builtin__ case? + if parent_path is not None: pd = os.path.abspath(parent_path) if pd == d[:len(pd)]: |