Skip to content

Commit 9e4935d

Browse files
committed
Modify sys.path in _build_backend
1 parent 0f3af65 commit 9e4935d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

pep517/_in_process.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,23 @@ def contained_in(filename, directory):
4747

4848
def _build_backend():
4949
"""Find and load the build backend"""
50+
# Add in-tree backend directories to the front of sys.path.
51+
backend_path = os.environ.get('PEP517_BACKEND_PATH')
52+
if backend_path:
53+
extra_pathitems = backend_path.split(os.pathsep)
54+
sys.path[:0] = extra_pathitems
55+
5056
ep = os.environ['PEP517_BUILD_BACKEND']
5157
mod_path, _, obj_path = ep.partition(':')
5258
try:
5359
obj = import_module(mod_path)
5460
except ImportError:
5561
raise BackendUnavailable(traceback.format_exc())
5662

57-
backend_path = os.environ.get('PEP517_BACKEND_PATH')
5863
if backend_path:
5964
if not any(
6065
contained_in(obj.__file__, path)
61-
for path in backend_path.split(os.pathsep)
66+
for path in extra_pathitems
6267
):
6368
raise BackendInvalid("Backend was not loaded from backend-path")
6469

@@ -222,11 +227,6 @@ def main():
222227

223228
hook_input = compat.read_json(pjoin(control_dir, 'input.json'))
224229

225-
# Add in-tree backend directories to the front of sys.path.
226-
backend_path = os.environ.get('PEP517_BACKEND_PATH')
227-
if backend_path:
228-
sys.path[:0] = backend_path.split(os.pathsep)
229-
230230
json_out = {'unsupported': False, 'return_val': None}
231231
try:
232232
json_out['return_val'] = hook(**hook_input['kwargs'])

0 commit comments

Comments
 (0)