Skip to content

Conversation

@rickeylev
Copy link
Collaborator

@rickeylev rickeylev commented Dec 11, 2025

When implicit namespace packages are used, it's common for multiple distributions
to install into the same directory, triggering the expensive conflict merging
logic. This can be observed wit our doc builds, where sphinxcontrib is a
namespace package that 7 distributions install into.

To fix, treat top-level directories that have an importable name and don't have an
__init__ looking file as implicit namespace packages and mark them as disallowed
from being directly linked. The importable name check is to exclude dist-info
directories.

@rickeylev rickeylev requested a review from aignas as a code owner December 11, 2025 08:07
@rickeylev
Copy link
Collaborator Author

Ah drat. The regex_match function is in Bazel 7, but not exposed. Well, no biggie, we can just check for . and - if that function isn't present; should work well enough.

@rickeylev
Copy link
Collaborator Author

There we go, fixed.

@rickeylev rickeylev enabled auto-merge December 11, 2025 20:59
@rickeylev rickeylev disabled auto-merge December 12, 2025 18:00
@rickeylev rickeylev added the do not merge Tag that prevents merging label Dec 12, 2025
@rickeylev
Copy link
Collaborator Author

Can't merge this yet; need to check on a bug it might introduced where top-level files that are merged via conflicts aren't being linked correct anymore i.e. nvidia/__init__.py is being created as a directory that contains all conflicting entries.

@rickeylev
Copy link
Collaborator Author

Well, there is a bug, but its not due to this PR. I'm not sure if its pre-existing or was introduced by #3448.

In any case, right now, the conflict merge logic won't produce the correct result if the same file is provided twice. It treats all the entries as directories, so tries to group the conflicting files under a directory named after the file. In practice, this would mostly only affect pkgutil namespace packages with non-trivial logic in __init__.py; it's uncommon for different distributions to overlap with other files.

@rickeylev
Copy link
Collaborator Author

Sent #3458 to fix that bug

@rickeylev rickeylev removed the do not merge Tag that prevents merging label Dec 13, 2025
@rickeylev rickeylev added the do not merge Tag that prevents merging label Dec 13, 2025
rickeylev and others added 3 commits December 14, 2025 12:21
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@rickeylev rickeylev removed the do not merge Tag that prevents merging label Dec 14, 2025
@rickeylev rickeylev enabled auto-merge December 14, 2025 20:54
@rickeylev
Copy link
Collaborator Author

dependent PR merged, PTAL

@rickeylev rickeylev added this pull request to the merge queue Dec 14, 2025
Merged via the queue into bazel-contrib:main with commit 1198422 Dec 14, 2025
4 checks passed
@rickeylev rickeylev deleted the refactor.optimize.venv.namespace.packages branch December 14, 2025 23:36
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