rules_python
rules_python copied to clipboard
[env python] failed on MacOS 12.3, as python2 removed
🐞 bug report
Affected Rule
The issue is caused by the rule:Is this a regression?
Yes, the previous version in which this bug was not present was: ....MacOS 12.2.1
Description
A clear and concise description of the problem...🔬 Minimal Reproduction
OS: MacOS 12.3 Bazel: 5.0.0
bazel5 run //examples:py_import_example
🔥 Exception or Error
INFO: Analyzed 2 targets (24 packages loaded, 318 targets configured).
INFO: Found 1 target and 1 test target...
[0 / 5] [Prepa] BazelWorkspaceStatusAction stable-status.txt ... (4 actions, 0 running)
FAIL: //:py_import_test (see /private/var/tmp/***/execroot/py_import/bazel-out/darwin-fastbuild/testlogs/py_import_test/test.log)
INFO: From Testing //:py_import_test:
==================== Test output for //:py_import_test:
env: python: No such file or directory
================================================================================
INFO: Elapsed time: 93.025s, Critical Path: 2.22s
INFO: 6 processes: 4 internal, 2 darwin-sandbox.
INFO: Build completed, 1 test FAILED, 6 total actions
//:py_import_test FAILED in 0.8s
/private/var/tmp/***/execroot/py_import/bazel-out/darwin-fastbuild/testlogs/py_import_test/test.log
Executed 1 out of 1 test: 1 fails locally.
INFO: Build completed, 1 test FAILED, 6 total actions
copying workspace under test examples/py_import to /private/var/tmp/***/execroot/rules_python/_tmp/12d36418595ed21d10a139c999170d5f/tmp4adyy1pw/wksp
testlogs/py_import_test/test.log:
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //:py_import_test
-----------------------------------------------------------------------------
env: python: No such file or directory
🌍 Your Environment
Operating System:
MacOS 12.3
M1 pro
Output of bazel version:
5.0.0
Rules_python version:
commit/e18e1a3bbd372fd0351277794155b5b9045fbe37
Anything else relevant?
Thanks for your issue report. Unfortunately, by default rules_python will lookup python on the system in its stub script.
The workarounds are:
- install
pythononto the system or alias an existingpython3. - Replace
pythonin the stub script, similar to https://github.com/bazelbuild/rules_python/pull/699.
Thanks for your issue report. Unfortunately, by default
rules_pythonwill lookuppythonon the system in its stub script.The workarounds are:
- install
pythononto the system or alias an existingpython3.- Replace
pythonin the stub script, similar to Add ability for Bazel >=5.0.0 users to use downloaded py interpreter in py_binary stub script #699.
Unfortunately, rules_apple does not seem to export the PATH set by the user (cf. run.use_default_shell_env)
so this can not work
install python onto the system or alias an existing python3.
Same root cause as: https://github.com/bazelbuild/rules_python/issues/691
A solution showcase
py_runtime(
name = "python3_runtime",
files = ["@python_interpreter//:files"],
interpreter = "@python_interpreter//:interpreter",
python_version = "PY3",
# https://github.com/bazelbuild/bazel/pull/11434
# https://github.com/bazelbuild/rules_python/issues/660
stub_shebang = select({
# fix macos>=12.3 without python
"@platforms//os:macos": "#!/usr/bin/env python3",
"//conditions:default": "",
}),
visibility = ["//visibility:public"],
)
This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"