mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 04:44:15 +02:00
fix: when global python libraries are not set in PATH
This commit is contained in:
@@ -1,12 +1,22 @@
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
from subprocess import PIPE
|
from subprocess import PIPE
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
# default environment variables for subprocesses.
|
# default environment variables for subprocesses.
|
||||||
from bauh.api.abstract.handler import ProcessWatcher
|
from bauh.api.abstract.handler import ProcessWatcher
|
||||||
|
|
||||||
GLOBAL_INTERPRETER_PATH = ':'.join(os.getenv('PATH').split(':')[1:])
|
PY_VERSION = "{}.{}".format(sys.version_info.major, sys.version_info.minor)
|
||||||
|
GLOBAL_PY_LIBS = '/usr/lib/python{}'.format(PY_VERSION)
|
||||||
|
|
||||||
|
PATH = os.getenv('PATH')
|
||||||
|
|
||||||
|
GLOBAL_INTERPRETER_PATH = ':'.join(PATH.split(':')[1:])
|
||||||
|
|
||||||
|
if GLOBAL_PY_LIBS not in PATH:
|
||||||
|
PATH = '{}:{}'.format(GLOBAL_PY_LIBS, PATH)
|
||||||
|
|
||||||
USE_GLOBAL_INTERPRETER = bool(os.getenv('VIRTUAL_ENV'))
|
USE_GLOBAL_INTERPRETER = bool(os.getenv('VIRTUAL_ENV'))
|
||||||
|
|
||||||
|
|
||||||
@@ -15,6 +25,8 @@ def gen_env(global_interpreter: bool) -> dict:
|
|||||||
|
|
||||||
if global_interpreter: # to avoid subprocess calls to the virtualenv python interpreter instead of the global one.
|
if global_interpreter: # to avoid subprocess calls to the virtualenv python interpreter instead of the global one.
|
||||||
res['PATH'] = GLOBAL_INTERPRETER_PATH
|
res['PATH'] = GLOBAL_INTERPRETER_PATH
|
||||||
|
else:
|
||||||
|
res['PATH'] = PATH
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user