Skip to content

Commit c5ee768

Browse files
authored
Bugfix: inherit Python interpreter when running check tools (#940)
Signed-off-by: Matthias Büchse <[email protected]>
1 parent 621b573 commit c5ee768

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Tests/scs-compliance-check.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ def run_check_tool(executable, args, env=None, cwd=None):
7373
if executable.startswith("file://"):
7474
executable = executable[7:]
7575
exe = [os.path.abspath(os.path.join(cwd or ".", executable)), *shlex.split(args)]
76+
# use the same interpreter for Python in order to inherit virtual env
77+
# necessary in cases where the interpreter is used from a virtual env that has not been activated
78+
# (I think this case should be supported if possible with little effort)
79+
if exe and exe[0].endswith('.py'):
80+
# logger.debug(f'using interpreter {sys.executable}')
81+
exe.insert(0, sys.executable)
7682
return subprocess.run(
7783
exe, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
7884
encoding='UTF-8', check=False, env=env, cwd=cwd,

0 commit comments

Comments
 (0)