File tree Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change 6
6
and will eventually be removed.
7
7
"""
8
8
9
+ import os
9
10
import sys
10
11
11
12
from setuptools .build_meta import _BuildMetaBackend
@@ -25,14 +26,21 @@ def run_setup(self, setup_script='setup.py'):
25
26
# In order to maintain compatibility with scripts assuming that
26
27
# the setup.py script is in a directory on the PYTHONPATH, inject
27
28
# '' into sys.path. (pypa/setuptools#1642)
28
- sys_path = list (sys .path ) # Save the old path
29
- if '' not in sys .path :
30
- sys .path .insert (0 , '' )
31
-
32
- super (_BuildMetaLegacyBackend ,
33
- self ).run_setup (setup_script = setup_script )
34
-
35
- sys .path = sys_path # Restore the old path
29
+ sys_path = list (sys .path ) # Save the original path
30
+
31
+ try :
32
+ if '' not in sys .path :
33
+ sys .path .insert (0 , '' )
34
+
35
+ super (_BuildMetaLegacyBackend ,
36
+ self ).run_setup (setup_script = setup_script )
37
+ finally :
38
+ # While PEP 517 frontends should be calling each hook in a fresh
39
+ # subprocess according to the standard (and thus it should not be
40
+ # strictly necessary to restore the old sys.path), we'll restore
41
+ # the original path so that the path manipulation does not persist
42
+ # within the hook after run_setup is called.
43
+ sys .path [:] = sys_path
36
44
37
45
38
46
_BACKEND = _BuildMetaLegacyBackend ()
You can’t perform that action at this time.
0 commit comments