Skip to content

Conversation

@tpudlik
Copy link
Collaborator

@tpudlik tpudlik commented Nov 10, 2023

Only append the [proto_root] to PYTHONPATH when it's actually necessary, i.e. when the generated Python modules are under _virtual_imports. Do no append it in the general case, when [proto_root] is just the repository root.

This makes it much less likely that adding a transitive dep on a py_proto_library will reorder the PYTHONPATH. Such reordering is undesirable because it may lead to import errors.

Fixes #1551

Only append the `[proto_root]` to PYTHONPATH when it's actually
necessary, i.e. when the generated Python modules are under
_virtual_imports. Do no append it in the general case, when
`[proto_root]` is just the repository root.

Fixes bazel-contrib#1551
@tpudlik tpudlik requested a review from rickeylev as a code owner November 10, 2023 19:34
Copy link
Collaborator

@aignas aignas left a comment

Choose a reason for hiding this comment

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

LGTM, but I would wait for @rickeylev and/or @linzhp to also chime in.

Could you also please add a CHANGELOG.md entry and make the PR description be more like a commit message (which it will become)?

@tpudlik
Copy link
Collaborator Author

tpudlik commented Nov 13, 2023

I updated the PR description.

Re CHANGELOG.md: the bug this fixes was never released, so is a changelog entry still desirable?

@aignas aignas added this pull request to the merge queue Nov 14, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 14, 2023
@aignas aignas added this pull request to the merge queue Nov 14, 2023
Merged via the queue into bazel-contrib:main with commit 85e50d2 Nov 14, 2023
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.

py_proto_library prepends too aggressively to the PYTHONPATH

3 participants