Skip to content

Commit

Permalink
use PYTHON_SYS_EXECUTABLE for setting path to Python
Browse files Browse the repository at this point in the history
  • Loading branch information
dae committed Dec 23, 2020
1 parent 5dd0eaf commit 355e4cd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions python.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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", """
Expand Down

0 comments on commit 355e4cd

Please sign in to comment.