Skip to content

feat(windows): site-packages venv support#3718

Merged
rickeylev merged 25 commits intobazel-contrib:mainfrom
rickeylev:win.venv.site.packages
Apr 21, 2026
Merged

feat(windows): site-packages venv support#3718
rickeylev merged 25 commits intobazel-contrib:mainfrom
rickeylev:win.venv.site.packages

Conversation

@rickeylev
Copy link
Copy Markdown
Collaborator

This implements Windows support for library files being populated
in the venv site-packages directory (i.e. --venv_site_packages=yes).

This is mostly just an expansion of the work done to make venvs work
on Windows. It mostly just adds the site-packages paths to the list
of (venv_path, symlinks) values that is currently used for the
interpreter files.

The main notable change is that creation of the site-packages
directory also requires traversing the whole site-packages directory
and re-creating its structure in the temporary venv. This isn't ideal,
but there isn't much other option.

Work towards #3245

@rickeylev rickeylev requested a review from aignas as a code owner April 20, 2026 03:20
@rickeylev
Copy link
Copy Markdown
Collaborator Author

I think this is the last piece to bring venv support on windows on par
with linux.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates documentation dependencies and implements robust support for Python virtual environments on Windows, specifically addressing symlink limitations and sys.path configuration. Changes include the introduction of an ExplicitSymlink provider, a recursive symlink tree helper for Windows, and refined bootstrap logic to correctly prioritize venv site-packages. Review feedback identifies several improvement opportunities for the Windows-specific logic, such as enabling link following in os.walk, utilizing UNC prefixes for long path support, and using exist_ok=True in os.makedirs to avoid errors. An optimization for symlink creation was also suggested to improve performance during venv setup.

Comment thread python/private/python_bootstrap_template.txt
Comment thread python/private/python_bootstrap_template.txt
Comment thread python/private/python_bootstrap_template.txt
Comment thread python/private/python_bootstrap_template.txt
@rickeylev rickeylev added this pull request to the merge queue Apr 21, 2026
@rickeylev rickeylev removed this pull request from the merge queue due to a manual request Apr 21, 2026
@rickeylev rickeylev enabled auto-merge April 21, 2026 02:46
@rickeylev rickeylev added this pull request to the merge queue Apr 21, 2026
Merged via the queue into bazel-contrib:main with commit 547521e Apr 21, 2026
4 checks passed
@rickeylev rickeylev deleted the win.venv.site.packages branch April 21, 2026 03:07
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.

2 participants