Uh oh!
There was an error while loading. Please reload this page.
fix: make sys.executable work with script bootstrap - #2409
Conversation
bd85a4c to
d68262cCompareaignas
commented
Nov 19, 2024
FYI, I am curious if the next version of this and #2359 combined could make it easy to have a |
3ea4bcc to
287b7bfCompare287b7bf to
028f9d1Comparerickeylev
commented
Nov 19, 2024
I'm not sure I follow. With this PR, each binary will have its own venv, so an editor could be pointed to that directly. Do you mean something like, you do a one time setup to point your editor to some "well known path", and then run |
aignas
commented
Nov 19, 2024
I think you understood it. I was thinking that you could do either: or tell VSCode or similar that the Python interpreter for We could also symlink it to a well known location using https://github.com/buildbuddy-io/bazel_env.bzl |
rickeylev
commented
Nov 19, 2024
Ok, ready for review |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
rickeylev
left a comment
There was a problem hiding this comment.
Addressed most, still have 1 or 2 left. Thanks!
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…o fix.script.boot.sys.exe
Co-authored-by: Ignas Anikevicius <240938+aignas@users.noreply.github.com>
Co-authored-by: Ignas Anikevicius <240938+aignas@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
ewianda
commented
Nov 21, 2024
❤️ |
ewianda
commented
Nov 22, 2024
hi @rickeylev this doesn't seem to be working, Not sure if it is my system or what. |
ewianda
commented
Nov 22, 2024
Hmm actually it fails on WSL Ubuntu and is fine on a regular Linux Machine. Says a broken symbolic link |
When
--bootstrap_impl=scriptis used,PYTHONPATHis no longer used to set the importpaths, which means subprocesses no longer inherit the Bazel paths. This is generally a
good thing, but breaks when
sys.executableis used to directly invoke the interpreter.Such an invocation assumes the interpreter will have the same packages available and works
with the system_python bootstrap.
To fix, have the script bootstrap use a basic virtual env. This allows it to intercept
interpreter startup even when the Bazel executable isn't invoked. Under the hood, there's
two pieces to make this work. The first is a binary uses
declare_symlink()to write arelative-path based symlink that points to the underlying Python interpreter. The second
piece is a site init hook (triggered by a
.pthfile using animportline) performssys.path setup as part of site (
import site) initialization.Fixes#2169