@@ -27,18 +27,21 @@ def get_path(mod_name, parent_path=None):
27
27
Returned path is relative to parent_path when given,
28
28
otherwise it is absolute path.
29
29
"""
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__' :
35
31
#builtin if/then added by Pearu for use in core.run_setup.
36
32
d = os .path .dirname (os .path .abspath (sys .argv [0 ]))
37
33
else :
38
34
__import__ (mod_name )
39
35
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
+
42
45
if parent_path is not None :
43
46
pd = os .path .abspath (parent_path )
44
47
if pd == d [:len (pd )]:
0 commit comments