Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make script bootstrap the default #2521

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

Open
1 of 4 tasks
rickeylev opened this issue Dec 23, 2024 · 0 comments
Open
1 of 4 tasks

Make script bootstrap the default #2521

rickeylev opened this issue Dec 23, 2024 · 0 comments
Assignees
Labels
core-rules Issues concerning core bin/test/lib rules P1 type: toolchain Related to the toolchains provided by rules_python

Comments

@rickeylev
Copy link
Collaborator

rickeylev commented Dec 23, 2024

This is a general tracking issue for making the default bootstrap method the "script" implementatation (i.e. --bootstrap_impl=script).

The current default is "system_python", which has the problem that it relies on the system having some Python already installed and available via shebang in order to run a py_binary (which often has its own interpreter).

TODO

@rickeylev rickeylev self-assigned this Dec 23, 2024
@aignas aignas marked this as a duplicate of #2727 Apr 2, 2025
@rickeylev rickeylev added P1 core-rules Issues concerning core bin/test/lib rules type: toolchain Related to the toolchains provided by rules_python labels Apr 20, 2025
@rickeylev rickeylev added this to the Bootstrap script milestone Apr 20, 2025
github-merge-queue bot pushed a commit that referenced this issue Apr 21, 2025
…ux (#2760)

Various cleanup and prep work to switch bootstrap=script to be the
default.

* Change `bootstrap_impl` to always be disabled for windows. This allows
setting it to
true in a bazelrc without worrying about the target platform. This is
done by using
FeatureFlagInfo to force the value to disabled for windows. This allows
any downstream
usages of the flag to Just Work and not have to add selects() for
windows themselves.
* Switch pip_repository_annotations test to `import python.runfiles`.
The script bootstrap
doesn't add the runfiles root to sys.path, so `import rules_python`
stops working.

* Switch gazelle workspace to using the runtime-env toolchain. It was
previously
implicitly using the deprecated one built into bazel, which doesn't
provide various
  necessary provider fields.
* Make the local toolchain use `sys._base_executable` instead of
`sys.executable`
when finding the interpreter. Otherwise, it might find a venv
interpreter or not
  properly handle wrapper scripts like pyenv.
* Adds a toolchain attribute/field to indicate if the toolchain supports
a build-time
created venv. This is due to the runtime_env toolchain. See PR comments
for details,
but in short: if we don't know the python interpreter path and version
at
  build time, the venv may not properly activate or find site-packages.

If it isn't supported, then the stage1 bootstrap creates a temporary
venv, similar
to how the zip case is handled. Unfortunately, this requires invoking
Python itself
as part of program startup, but I don't see a way around that -- note
this is
  only triggered by the runtime-env toolchain.

* Make the runtime-env toolchain better support virtualenvs. Because
it's a wrapper
that re-invokes Python, Python can't automatically detect its in a venv.
Two
tricks are used (`exec -a` and PYTHONEXECUTABLE) to help address this
(but they
  aren't guaranteed to work, hence the "recreate at runtime" logic).
* Fix a subtle issue where `sys._base_executable` isn't set correctly
due to `home`
missing in the pyvenv.cfg file. This mostly only affected the creation
of venvs
  from within the bazel-created venv.
* Change the bazel site init to always add the build-time created
site-packages
(if it exists) as a site directory. This matches the system_python
bootstrap
behavior a bit better, which just shoved everything onto sys.path using
  PYTHONPATH.
* Skip running runtime_env_toolchains tests on RBE. RBE's system python
is 3.6,
but the script bootstrap uses 3.9 features. (Running it on RBE is
questionable
  anyways).

Along the way...

* Ignore gazelle convenience symlinks
* Switch pip_repository_annotations test to use
non-legacy_external_runfiles based
  paths. The legacy behavior is disabled in Bazel 8+ by default.
* Also document why the script bootstrap doesn't add the runfiles root
to sys.path.

Work towards #2521

---------

Co-authored-by: Ignas Anikevicius <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-rules Issues concerning core bin/test/lib rules P1 type: toolchain Related to the toolchains provided by rules_python
Projects
None yet
Development

No branches or pull requests

1 participant