Skip to content

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

Closed
@honwen

Description

@honwen

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

Activity

thundergolfer

thundergolfer commented on Jun 14, 2022

@thundergolfer

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

The workarounds are:

honwen

honwen commented on Jul 12, 2022

@honwen
Author

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

groodt commented on Jul 13, 2022

@groodt
Collaborator

Same root cause as: #691

added
Can Close?Will close in 30 days if there is no new activity
on Aug 14, 2022
honwen

honwen commented on Aug 16, 2022

@honwen
Author

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"],
)
added
Can Close?Will close in 30 days if there is no new activity
and removed on Sep 10, 2022
github-actions

github-actions commented on Oct 10, 2022

@github-actions

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Can Close?Will close in 30 days if there is no new activity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @groodt@thundergolfer@honwen

        Issue actions

          [env python] failed on MacOS 12.3, as python2 removed · Issue #660 · bazel-contrib/rules_python