Skip to content

Commit 4594e8a

Browse files
Thrift does not need to set python_source_root (#5)
That's because Thrift already generates all the `__init__.py` files we need for us for imports to work. Quite convenient! See the table at https://www.pantsbuild.org/v2.10/docs/thrift-python#step-4-confirm-python-imports-are-working for what Pants generates (found via `export-codegen` goal). There is no benefit to relocating. I will be removing this field from pantsbuild/pants shortly.
1 parent 7723218 commit 4594e8a

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ An example repository to demonstrate codegen support in Pants.
44

55
Refer to these docs for more information:
66

7-
* [Python Protobuf](https://www.pantsbuild.org/docs/protobuf-python
8-
* [Python Thrift](https://www.pantsbuild.org/docs/protobuf-python
7+
* [Python Protobuf](https://www.pantsbuild.org/docs/protobuf-python)
8+
* [Python Thrift](https://www.pantsbuild.org/docs/protobuf-python)
99

1010
Run `./pants export-codegen ::` to see the generated files. This isn't necessary for Pants to
1111
use the generated files, but can be useful when debugging or to generate files for IDEs.

src/protobuf/simple_example/BUILD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
protobuf_sources(
2+
# This will generate files under `src/python`, rather than `src/protobuf`, which is convenient
3+
# so that we do not need to add `__init__.py` files to `src/protobuf`. See
4+
# https://www.pantsbuild.org/docs/protobuf-python#protobuf-and-source-roots
25
python_source_root="src/python",
36
)

src/thrift/BUILD

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
thrift_sources(
2-
python_source_root="src/python",
3-
)
1+
thrift_sources()

0 commit comments

Comments
 (0)