diff --git a/.bazelrc b/.bazelrc index 4f9c6392748..8718efc2667 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,8 +1,9 @@ common --enable_platform_specific_config 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:linux --action_env="PYTHON_SYS_EXECUTABLE=/usr/local/bin/python3.8" # runfiles are off by default on Windows, and we need them build --enable_runfiles diff --git a/docs/linux.md b/docs/linux.md index d5bfc017854..7729b667bff 100644 --- a/docs/linux.md +++ b/docs/linux.md @@ -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: ``` -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 diff --git a/python.bzl b/python.bzl index 67b7d72c1b7..8926cb67265 100644 --- a/python.bzl +++ b/python.bzl @@ -8,13 +8,16 @@ def _impl(rctx): "python.exe", ] path = None - for name in names: - path = rctx.which(name) - if path: - break + if rctx.os.environ.get("PYTHON_SYS_EXECUTABLE"): + path = rctx.os.environ.get("PYTHON_SYS_EXECUTABLE") + else: + for name in names: + path = rctx.which(name) + if path: + break 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.file("BUILD.bazel", """