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

feat: make bootstrap=script default for linux #2760

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rickeylev
Copy link
Collaborator

@rickeylev rickeylev commented Apr 9, 2025

wip

DO NOT MERGE:

@rickeylev rickeylev force-pushed the feat.default.bootstrap.script branch from 3b827f4 to 902ca8a Compare April 9, 2025 16:23
@rickeylev rickeylev force-pushed the feat.default.bootstrap.script branch from 902ca8a to 0fb8f52 Compare April 9, 2025 16:54
@rickeylev
Copy link
Collaborator Author

Hrm. CI flagged an issue relating to the runtime-env toolchain: it doesn't respect the virtual env.

This is because the {name}.venv/bin/<interpreter> created is a wrapper script. It's still a symlink, but it points back to a .sh script that calls /usr/bin/python3 "$@". As far as that python interpreter is concerned, it's not in a venv. I remember trying to work around this when I first worked on the venv stuff and couldn't figure out a workaround. This might be the spell the end of the runtime env toolchain.

There's another CI failure relating to compile_pip_requirements, but I haven't had a chance to look yet.

@rickeylev
Copy link
Collaborator Author

rickeylev commented Apr 10, 2025

note to self:

@rickeylev
Copy link
Collaborator Author

rickeylev commented Apr 13, 2025

Ok, so what I've figured out is:

  1. Using exec -a mostly works, but not with pyenv wrappers.
  2. Using PYTHONEXECUTABLE envvar works, but only with python 3.11+
  3. Because venvs contain the python version in lib/pythonX.Y/site-packages, a mis-match in the build-time python version vs runtime will break the whole app (it's relying on bazel_site_init.py in site-packages to do init).

(1) and (2) mean, in order to use py3.9 with runtime-venv toolchain, the only way to make it even see the venv is to create it at runtime with the typical symlink. This would also solve (3) (symlink lib/python3.11 to python3.10; technically wrong, but matches historical behavior); I can think of some alternatives for (3) that might work right now (PYTHONPATH, addsitedir(), or sys.path setup in stage2), but in order to have a normally functioning venv site-packages dir, we have to create lib/pythonX.Y matching the current runtime version.

Anyways, what I'm thinking is to add something to the toolchain definition that says "recreate the venv at runtime", and then the runtime env toolchain sets this. We already have a flag for this due to rules_pkg not handling raw symlinks. I think having a "create venv at runtime" thing is gonna be a fact of life for awhile, at least until 3.11 is the minimum supported version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant