mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-02-05 23:13:46 +08:00
latest
This commit is contained in:
parent
50c70ff850
commit
83bbca6ffe
@ -65,30 +65,33 @@ def pcommand_main(globs: dict[str, Any]) -> None:
|
|||||||
# So let's go ahead and set up PATH here so tools/pcommand by itself
|
# So let's go ahead and set up PATH here so tools/pcommand by itself
|
||||||
# *does* do the right thing.
|
# *does* do the right thing.
|
||||||
|
|
||||||
abs_exe_path = Path(sys.executable).absolute()
|
# Don't do this on Windows; we're not currently using virtual-envs
|
||||||
pathparts = abs_exe_path.parts
|
# there for the little bit of tools stuff we support.
|
||||||
if (
|
if not sys.platform.startswith('win'):
|
||||||
len(pathparts) < 3
|
abs_exe_path = Path(sys.executable).absolute()
|
||||||
or pathparts[-3] != '.venv'
|
pathparts = abs_exe_path.parts
|
||||||
or pathparts[-2] != 'bin'
|
if (
|
||||||
or not pathparts[-1].startswith('python')
|
len(pathparts) < 3
|
||||||
):
|
or pathparts[-3] != '.venv'
|
||||||
raise RuntimeError(
|
or pathparts[-2] != 'bin'
|
||||||
'Unexpected Python environment;'
|
or not pathparts[-1].startswith('python')
|
||||||
' we expect to be running using .venv/bin/pythonX.Y'
|
):
|
||||||
)
|
raise RuntimeError(
|
||||||
|
'Unexpected Python environment;'
|
||||||
|
' we expect to be running using .venv/bin/pythonX.Y'
|
||||||
|
)
|
||||||
|
|
||||||
cur_paths_str = os.environ.get('PATH')
|
cur_paths_str = os.environ.get('PATH')
|
||||||
if cur_paths_str is None:
|
if cur_paths_str is None:
|
||||||
raise RuntimeError("'PATH' is not currently set; unexpected.")
|
raise RuntimeError("'PATH' is not currently set; unexpected.")
|
||||||
|
|
||||||
venv_bin_dir = str(abs_exe_path.parent)
|
venv_bin_dir = str(abs_exe_path.parent)
|
||||||
|
|
||||||
# Only add our entry if it's not already there; don't want PATH to
|
# Only add our entry if it's not already there; don't want PATH to
|
||||||
# get out of control if we're doing recursive stuff.
|
# get out of control if we're doing recursive stuff.
|
||||||
cur_paths = cur_paths_str.split(':')
|
cur_paths = cur_paths_str.split(':')
|
||||||
if venv_bin_dir not in cur_paths:
|
if venv_bin_dir not in cur_paths:
|
||||||
os.environ['PATH'] = ':'.join([venv_bin_dir] + cur_paths)
|
os.environ['PATH'] = ':'.join([venv_bin_dir] + cur_paths)
|
||||||
|
|
||||||
# Build our list of available command functions.
|
# Build our list of available command functions.
|
||||||
_g_funcs = dict(
|
_g_funcs = dict(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user