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

OSX enviroment PATH gets truncated #1571

Closed
k6project opened this issue Jul 26, 2016 · 5 comments
Closed

OSX enviroment PATH gets truncated #1571

k6project opened this issue Jul 26, 2016 · 5 comments
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Rules-Python Native rules for Python type: bug
Milestone

Comments

@k6project
Copy link

Hi,

I have py_binary rule with PY3 set as default_python_version. When the build runs, it fails to locate python3:

Traceback (most recent call last):
File "bazel-out/local-py3-fastbuild/bin/testws/test-builder", line 122, in
Main()
File "bazel-out/local-py3-fastbuild/bin/testws/test-builder", line 107, in Main
raise AssertionError('Could not find python binary: ' + PYTHON_BINARY)
AssertionError: Could not find python binary: python3

I have modified standard template for the script to print every path it checks. Seems like environment path is truncated to /bin:/usr/bin

The problem is that under OSX python3 (installed via Homebrew) is under /usr/local/bin

What would be a correct way to adjust default environment?

@damienmg
Copy link
Contributor

The python binary is mostly hard coded IIRC, you need to set --python3_path in the command line.

@damienmg
Copy link
Contributor

Also it seems like the python rules does not pass around the default shell environment.

@damienmg damienmg added type: bug P3 We're not considering working on this, but happy to review a PR. (No assignee) category: rules > python labels Jul 26, 2016
@damienmg damienmg added this to the 1.0 milestone Jul 26, 2016
@brandjon
Copy link
Member

Related issue about invoking the python interpreter, though sounds like a different cause: #4815.

@brandjon brandjon added team-Rules-Python Native rules for Python and removed category: rules > python labels Oct 18, 2018
@brandjon
Copy link
Member

brandjon commented Mar 13, 2019

The plan is that this will be addressed by Python toolchains (#7375). In the meantime, you can set the Python version with --python_top / py_runtime, or with --python_path.

Both of those will ignore whether the target is configured for PY2 or PY3 though, due to #4815. See the --python_top / py_runtime based workaround there.

I'll close this as a dup of the toolchain feature work and that bug.

@brandjon
Copy link
Member

@k6project Rereading your initial post I may have acted hastily -- Are you saying that you are identifying the Python binary by its executable name (not path), e.g. via --python_path=python3, and that it's not finding it even though the right directory is on PATH in your env?

In that case Damien's point about passing the shell env is probably the issue, but it's not obvious that we want the user's shell env to affect the behavior of the stub template. This can be worked around in a more robust way by using an absolute path, for instance, especially in a py_runtime target/toolchain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Rules-Python Native rules for Python type: bug
Projects
None yet
Development

No branches or pull requests

3 participants