use PYTHON_SYS_EXECUTABLE for setting path to Python

This commit is contained in:
Damien Elmes 2020-12-23 21:51:26 +10:00
parent 5dd0eaf0a2
commit 355e4cd519
3 changed files with 11 additions and 7 deletions

View file

@ -1,8 +1,9 @@
common --enable_platform_specific_config common --enable_platform_specific_config
common --experimental_repository_cache_hardlinks common --experimental_repository_cache_hardlinks
# specify python path on Windows for pyo3 compile # specify python path for pyo3 compile
build:windows --action_env="PYTHON_SYS_EXECUTABLE=c:\\python\\python.exe" build:windows --action_env="PYTHON_SYS_EXECUTABLE=c:\\python\\python.exe"
#build:linux --action_env="PYTHON_SYS_EXECUTABLE=/usr/local/bin/python3.8"
# runfiles are off by default on Windows, and we need them # runfiles are off by default on Windows, and we need them
build --enable_runfiles build --enable_runfiles

View file

@ -31,7 +31,7 @@ other than /usr/bin, you'll need to put the following into a file called user.ba
at the top of this repo before proceeding: at the top of this repo before proceeding:
``` ```
build --action_env=PYTHON_SYS_EXECUTABLE=/usr/local/bin/python build --action_env=PYTHON_SYS_EXECUTABLE=/usr/local/bin/python3.8
``` ```
If you're building Anki from a docker container or distro that has no `python` command in If you're building Anki from a docker container or distro that has no `python` command in

View file

@ -8,13 +8,16 @@ def _impl(rctx):
"python.exe", "python.exe",
] ]
path = None path = None
for name in names: if rctx.os.environ.get("PYTHON_SYS_EXECUTABLE"):
path = rctx.which(name) path = rctx.os.environ.get("PYTHON_SYS_EXECUTABLE")
if path: else:
break for name in names:
path = rctx.which(name)
if path:
break
if not path: if not path:
fail("python3 or python.exe not found on path") fail("python3 or python.exe not found on path, and PYTHON_SYS_EXECUTABLE not set")
rctx.symlink(path, "python") rctx.symlink(path, "python")
rctx.file("BUILD.bazel", """ rctx.file("BUILD.bazel", """