8000 Fixed get_path bug fix. · numpy/numpy@44f0e40 · GitHub
[go: up one dir, main page]

Skip to content

Commit 44f0e40

Browse files
committed
Fixed get_path bug fix.
1 parent 2eb3a4b commit 44f0e40

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

numpy/distutils/misc_util.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,21 @@ def get_path(mod_name, parent_path=None):
2727
Returned path is relative to parent_path when given,
2828
otherwise it is absolute path.
2929
"""
30-
if mod_name == '__main__' and not hasattr('__main__', '__file__'):
31-
# we're probably running setup.py as execfile("setup.py")
32-
# (likely we're building an egg)
33-
d = os.path.abspath('.')
34-
elif mod_name == '__builtin__':
30+
if mod_name == '__builtin__':
3531
#builtin if/then added by Pearu for use in core.run_setup.
3632
d = os.path.dirname(os.path.abspath(sys.argv[0]))
3733
else:
3834
__import__(mod_name)
3935
mod = sys.modules[mod_name]
40-
filename = mod.__file__
41-
d = os.path.dirname(os.path.abspath(filename))
36+
if hasattr(mod,'__file__'):
37+
filename = mod.__file__
38+
d = os.path.dirname(os.path.abspath(mod.__file__))
39+
else:
40+
# we're probably running setup.py as execfile("setup.py")
41+
# (likely we're building an egg)
42+
d = os.path.abspath('.')
43+
# hmm, should we use sys.argv[0] like in __builtin__ case?
44+
4245
if parent_path is not None:
4346
pd = os.path.abspath(parent_path)
4447
if pd == d[:len(pd)]:

0 commit comments

Comments
 (0)
0