Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[env python] failed on MacOS 12.3, as python2 removed #660

Closed
honwen opened this issue Mar 17, 2022 · 5 comments
Closed

[env python] failed on MacOS 12.3, as python2 removed #660

honwen opened this issue Mar 17, 2022 · 5 comments
Labels
Can Close? Will close in 30 days if there is no new activity

Comments

@honwen
Copy link

honwen commented Mar 17, 2022

🐞 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?

@thundergolfer
Copy link
Collaborator

Thanks for your issue report. Unfortunately, by default rules_python will lookup python on the system in its stub script.

The workarounds are:

@honwen
Copy link
Author

honwen commented Jul 12, 2022

Thanks for your issue report. Unfortunately, by default rules_python will lookup python on the system in its stub script.

The workarounds are:

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.

@groodt
Copy link
Collaborator

groodt commented Jul 13, 2022

Same root cause as: #691

@groodt groodt added the Can Close? Will close in 30 days if there is no new activity label Aug 14, 2022
@honwen
Copy link
Author

honwen commented Aug 16, 2022

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"],
)

@github-actions github-actions bot removed the Can Close? Will close in 30 days if there is no new activity label Aug 16, 2022
@groodt groodt added Can Close? Will close in 30 days if there is no new activity and removed type: bug labels Sep 10, 2022
@github-actions
Copy link

This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Can Close? Will close in 30 days if there is no new activity
Projects
None yet
Development

No branches or pull requests

3 participants