File tree 2 files changed +11
-4
lines changed
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change
1
+ Fix isolate script to only remove current working directory.
Original file line number Diff line number Diff line change 4
4
if __name__ != "__main__" :
5
5
raise Exception ("{} cannot be imported" .format (__name__ ))
6
6
7
+ import os
7
8
import os .path
8
9
import runpy
9
10
import sys
10
11
11
- # We "isolate" the script/module (sys.argv[1]) by
12
- # replacing sys.path[0] with a dummy path and then sending the target
13
- # on to runpy.
14
- sys .path [0 ] = os .path .join (os .path .dirname (__file__ ), ".does-not-exist" )
12
+
13
+ def normalize (path ):
14
+ return os .path .normcase (os .path .normpath (path ))
15
+
16
+
17
+ # We "isolate" the script/module (sys.argv[1]) by removing current working
18
+ # directory or '' in sys.path and then sending the target on to runpy.
19
+ cwd = normalize (os .getcwd ())
20
+ sys .path [:] = (p for p in sys .path if p != "" and normalize (p ) != cwd )
15
21
del sys .argv [0 ]
16
22
module = sys .argv [0 ]
17
23
if module == "-c" :
You can’t perform that action at this time.
0 commit comments