fix(bootstrap): handle when runfiles env vars don't point to current binary's runfiles (#3192) The stage1 bootstrap script had a bug in the find_runfiles_root function where it would unconditionally use the RUNFILES_DIR et al environment variables if they were set. This failed in a particular nested context: an outer binary calling an inner binary when the inner binary isn't a data dependency of the outer binary (i.e. the outer doesn't contain the inner in runfiles). This would cause the inner binary to incorrectly resolve its runfiles, leading to failures. Such a case can occur if a genrule calls the outer binary, which has the inner binary passed as an arg. This change adds a check to validate that the script's entry point exists within the inherited RUNFILES_DIR before using it. If the entry point is not found, it proceeds with other runfiles discovery methods. This matches the system_python runfiles discovery logic. Fixes https://github.com/bazel-contrib/rules_python/issues/3187
This repository is the home of the core Python rules -- py_library, py_binary, py_test, py_proto_library, and related symbols that provide the basis for Python support in Bazel. It also contains package installation rules for integrating with PyPI and other indices.
Documentation for rules_python is at https://rules-python.readthedocs.io and in the Bazel Build Encyclopedia.
Examples live in the examples directory.
The core rules are stable. Their implementation is subject to Bazel's backward compatibility policy. This repository aims to follow semantic versioning.
The Bazel community maintains this repository. Neither Google nor the Bazel team provides support for the code. However, this repository is part of the test suite used to vet new Bazel releases. See How to contribute page for information on our development workflow.
For detailed documentation, see https://rules-python.readthedocs.io
See Bzlmod support for more details.