-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Windows, Python: --python_path
default value is useless on Windows
#3717
Comments
Symptom: I get a launcher error when I don't use
|
I am trying to reproduce this on my machine, but got
I'm using Bazel@HEAD, but it doesn't seem to use MSVC as the C++ compiler, how should I resolve this? |
It does not use MSVC as C++ compiler because it builds for Android |
Maybe you have a bazelrc file that Bazel is picking up? Try using Here's what I did:
|
Got it, my NDK repo had some problem, now it's working! Thanks! |
Hmm,, now I have some doubt on the proposed solution, in order to know when to pass Instead, how about having a @local_python_config rule? We can use skylark repository rule to configure a py_runtime rule. (py_runtime is introduced in a5c3862) @erain Do we have a plan to add a default py_runtime in Bazel? |
That's a good point. The @local_python_config rule sounds promising. Can you say more specifically how you'd use it? Alternatively, is it possible to pass the |
Just like the @local_config_cc repo, we configure a python runtime rule using skylark, then make Do you mean adding |
Ah, I just realized we can pretend we are adding This way it will be overridden by any |
I do prefer very strongly a principled solution with (We can add command line hackery in the meanwhile if we need to for some clients) |
I also prefer a principled solution, and |
On Windows, Bazel client will try to find python.exe in $PATH. If succeed, then we pretend to add a --python_path option in the least important bazelrc file. Fixed bazelbuild#3717 Change-Id: I8d97b0895f024d8d236f3b4b39f91c41d947a5fa PiperOrigin-RevId: 168659085
In release 4.1.0 Should |
Description of the problem / feature request / question:
The default value of
--python_path
ispython
. This only works on Linux/macOS, however not because on Windows the binary ispython.exe
but because on Windows it's not on the$PATH
.When Bazel runs a
py_binary
as an action's executable (e.g. as part of agenrule
), the action's$PATH
is not the same as client's but a sanitized one (for sake of reproducibility).On Linux/macOS, this sanitized
$PATH
includes/usr/bin
, which containspython
.On Windows, this
$PATH
contains the Windows and the MSYS directory, neither of which haspython
.Therefore to run Python tools in build actions we must pass the
--python_path
flag to Bazel.I get bitten by this every time I try to build the Android Hello World project.
Proposed solution
The Bazel client could detect the location of
python.exe
(by looking at the$PATH
) and add the--python_path
flag to the server's command line, like we do with--windows_unix_root
. (Caveat: the--python_path
flag is a command flag, not a startup flag, and the client should only pass it if the command is "build", "test", etc., i.e. commands where this flag is valid.)Environment info
Operating System: Windows 10
Bazel version (output of
bazel info release
): HEADThe text was updated successfully, but these errors were encountered: