fix(system_python): write import paths to generated file instead of using PYTHONPATH #3242
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
This changes the system_python bootstrap to use a 2-stage process like the script
bootstrap does. Among other things, this means the import paths are written to
a generated file (
bazel_site_init.py
, same as boostrap=script) and sys.pathsetup is performed by the Python code in stage 2.
Since the PYTHONPATH environment variable isn't used, this fixes the problem on
Windows where the value is too long.
This also better unifies the system_python and script based bootstraps because the
same stage 2 code and bazel_site_init code is used.
Along the way, several other improvements:
(stdlib, binary paths, runtime site packages).
-S
).interpreter_args
attribute andRULES_PYTHON_ADDITIONAL_INTERPRETER_ARGS
env var work with system_python.main_module
work with system_python.this because their environment doesn't install any shells as a security
precaution).
Fixes #2652