New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add __init__.py to directories created by grpcio #7984
Add __init__.py to directories created by grpcio #7984
Conversation
### Problem When trying to create a dist tarball from `python_grpcio_library` using `provides=setup_py`, the `find-namespace-packages` step fails with the following errors: $ ./pants setup-py ... [...] ..._pb2.py is source but does not belong to a package. ..._pb2_grpc.py is source but does not belong to a package. That happens because the `find_packages()` method in `setup_py.py` ignores subdirectories that do not contain `__init__.py`. ### Solution This commit adds an empty `__init__.py` file to each directory created by grpcio. ### Result A package with gRPC interfaces is properly created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for the contribution! The overall fix looks great (thanks for updating the tests too) - provided some ways to tie in with the rest of the codebase better.
tests/python/pants_test/backend/codegen/grpcio/test_multiple_grpcio_gen.py
Outdated
Show resolved
Hide resolved
Also looks like the lint shard failed due to import order. One tip: run In this particular instance, you can fix the import error by running |
Per PR: pantsbuild#7984
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for iterating on this!
Per PR: pantsbuild#7984
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! Ran this locally and confirmed the tests work for me. Was trying to see if we can workaround relative_to
but you're right that we need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Will merge this upon green CI. We have a few flaky tests, so if it’s red at first don’t worry that you caused it - I’ll monitor and restart.
Have a great 4th of July :)
Thank you, Eric! You too have a great 4th of July! :-) |
Problem
When trying to create a dist tarball from
python_grpcio_library
usingprovides=setup_py
, thefind-namespace-packages
step fails with the following errors:That happens because the
find_packages()
method insetup_py.py
ignores subdirectories that do not contain__init__.py
.Solution
This commit adds an empty
__init__.py
file to each directory created by grpcio.Result
A package with gRPC interfaces is properly created.