File tree 1 file changed +11
-3
lines changed 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,14 @@ def find_spec(
49
49
# if it's one of our modules, trigger a rebuild
50
50
if fullname .split ('.' , maxsplit = 1 )[0 ] in self ._top_level_modules :
51
51
self .rebuild ()
52
+ # prepend the project path to sys.path, so that the normal finder
53
+ # can find our modules
54
+ # we prepend so that our path comes before the current path (if
55
+ # the interpreter is run with -m), see gh-239
56
+ if sys .path [0 ] != self ._project_path :
57
+ if self ._project_path in sys .path :
58
+ sys .path .remove (self ._project_path )
59
+ sys .path .insert (0 , self ._project_path )
52
60
# return none (meaning we "didn't find" the module) and let the normal
53
61
# finders find/import it
54
62
return None
@@ -65,6 +73,6 @@ def install(
65
73
# prepend our finder to sys.meta_path, so that it is queried before
66
74
# the normal finders, and can trigger a project rebuild
67
75
sys .meta_path .insert (0 , finder )
68
- # add the project path to sys.path, so that the normal finder can
69
- # find our modules
70
- sys . path . append ( project_path )
76
+ # we add the project path to sys.path later , so that we can prepend
77
+ # after the current directory is prepended (when -m is used)
78
+ # see gh-239
You can’t perform that action at this time.
0 commit comments