Skip to content

Conversation

aignas
Copy link
Collaborator

@aignas aignas commented Oct 11, 2025

Before this PR we would not include pth files at the root of the
site-packages folder, but we would include if they are further down
the tree.

Fixes #3339
Fixes #2071

@aignas aignas requested a review from rickeylev as a code owner October 11, 2025 15:57
Copy link
Contributor

Summary of Changes

Hello @aignas, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue where Python .pth files located directly in the site-packages root of a virtual environment were not being included, unlike those in subdirectories. The changes involve updating file extension recognition, refining the virtual environment symlink generation logic to correctly process these top-level files, and adding a dedicated test to ensure their proper inclusion.

Highlights

  • .pth file recognition: The build system now explicitly recognizes .pth files by adding them to the PYTHON_FILE_EXTENSIONS list, ensuring they are considered during virtual environment creation.
  • Virtual environment symlink generation: The logic for generating virtual environment symlinks has been updated to correctly handle the full path of files, specifically addressing an issue where .pth files at the root of the site-packages directory were previously overlooked.
  • Test coverage: A new test case has been introduced to validate that top-level .pth files are properly included when --venvs_site_packages=yes is enabled, confirming the fix and preventing regressions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
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 fixes an issue where .pth files at the root of site-packages were not correctly included in virtual environments. The fix involves updating the file extension list and modifying how symlink entries are created for root-level files. The changes in the implementation look correct and address the problem. However, the new test case added to verify this fix is flawed, as it asserts an incorrect behavior and doesn't test the new code path. I've provided a detailed comment with a suggested replacement for the test to ensure the fix is properly validated.

Before this PR we would not include `pth` files at the root of the
`site-packages` folder, but we would include if they are further down
the tree.

Fixes bazel-contrib#3339
Fixes bazel-contrib#2071
@aignas aignas force-pushed the aignas.test.pth-files branch from ce0bb1b to 2f34140 Compare October 11, 2025 16:03
@aignas
Copy link
Collaborator Author

aignas commented Oct 11, 2025

/gemini review

Copy link
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 correctly addresses an issue where .pth files at the root of the site-packages folder were not being included in the virtual environment. The fix involves recognizing .pth as a valid Python file extension and adjusting the symlink creation logic to correctly handle these root-level files. The accompanying test changes effectively validate this fix. I have one suggestion to improve the maintainability of the test code.

Copy link
Collaborator

@rickeylev rickeylev left a comment

Choose a reason for hiding this comment

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

A functional test would be good, too, but I think its fine for that to be in another PR

@rickeylev rickeylev added this pull request to the merge queue Oct 11, 2025
Merged via the queue into bazel-contrib:main with commit f3e83e7 Oct 11, 2025
2 of 3 checks passed
aignas added a commit to aignas/rules_python that referenced this pull request Oct 13, 2025
As requested in bazel-contrib#3340, this adds a functional test for it all.

Tests for bazel-contrib#3339
github-merge-queue bot pushed a commit that referenced this pull request Oct 14, 2025
As requested in #3340, this adds a functional test for it all.

Tests for #3339

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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.

venv: pth files don't end up in site-packages pip_parse() does not correctly read *.pth files?

2 participants