Known issues

Running Bazel: MSYS2 shell vs. Command Prompt vs. PowerShell

It’s best to run Bazel from the Command Prompt (cmd.exe) or from PowerShell.

You can also run Bazel from the MSYS2 shell, but you need to disable MSYS2’s
automatic path conversion. See this StackOverflow
answer for details.

Setting environment variables

Environment variables you set in the Windows Command Prompt (cmd.exe) are only
set in that command prompt session. If you start a new cmd.exe, you need to
set the variables again. To always set the variables when cmd.exe starts, you
can add them to the User variables or System variables in the Control Panel >
System Properties > Advanced > Environment Variables... dialog box.

Using Bazel on Windows

The first time you build any target, Bazel auto-configures the location of
Python and the Visual C++ compiler. If you need to auto-configure again, run
bazel clean then build a target.

You can also tell Bazel where to find the Python binary and the C++ compiler:

Build Python

To tell Bazel where Python is, you can use --python_path=<path/to/python>.
For example:

bazel build --python_path=C:/Python27/python.exe ...

If --python_path is not specified, Bazel uses python.exe as
the interpreter and the binary looks for it in $PATH during runtime.
If it is not in $PATH(for example, when you use py_binary as an action’s
executable, Bazel will sanitize $PATH), then the execution will fail.

On Windows, Bazel builds two output files for py_binary rules:

a self-extracting zip file

an executable file that can launch the Python interpreter with the
self-extracting zip file as the argument

You can either run the executable file (it has a .exe extension) or you can run
Python with the self-extracting zip file as the argument.