Skip to content

Conversation

@linzhp
Copy link
Contributor

@linzhp linzhp commented Sep 8, 2023

When the proto_library has strip_import_prefix, the py files from proto are generated into a directory like bazel-bin/tests/py_proto_library/proto/_virtual_imports and symlinked in the runfiles as <runfilesroot>/<workspace name>/tests/py_proto_library/proto/_virtual_imports.
We need to add <workspace name>/tests/py_proto_library/proto/_virtual_imports to the imports of _PyProtoInfo, so it will be appended to PYTHONPATH.

Modified an existing example to demonstrate the scenario and verify the fix.

@linzhp linzhp requested a review from rickeylev as a code owner September 8, 2023 18:54
@linzhp linzhp changed the title fix: allowing to import code generated from proto fix: allowing to import code generated from proto with strip_import_prefix Sep 15, 2023
@aignas
Copy link
Collaborator

aignas commented Sep 26, 2023

Could you also please a line in the CHANGELOG.md?

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.

Thanks

@aignas aignas added this pull request to the merge queue Oct 12, 2023
Merged via the queue into bazel-contrib:main with commit bee35ef Oct 12, 2023
@linzhp linzhp deleted the proto branch October 12, 2023 18:03
linzhp added a commit to linzhp/rules_python that referenced this pull request Oct 15, 2023
…refix (bazel-contrib#1406)

When the `proto_library` has `strip_import_prefix`, the py files from
proto are generated into a directory like
`bazel-bin/tests/py_proto_library/proto/_virtual_imports` and symlinked
in the runfiles as `<runfilesroot>/<workspace
name>/tests/py_proto_library/proto/_virtual_imports`.
We need to add `<workspace
name>/tests/py_proto_library/proto/_virtual_imports` to the `imports` of
`_PyProtoInfo`, so it will be appended to `PYTHONPATH`.

Modified an existing example to demonstrate the scenario and verify the
fix.

---------

Co-authored-by: Ignas Anikevicius <240938+aignas@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.

2 participants