Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
Fix python package and publish typing information (#347)
Browse files Browse the repository at this point in the history
* Add __init__.py files to generated stubs

Signed-off-by: Eduardo Apolinario <[email protected]>

* Publish stubs in the package

Signed-off-by: Eduardo Apolinario <[email protected]>

* Include __init__.py in verification workflow

Signed-off-by: Eduardo Apolinario <[email protected]>

* Bump versions of remote plugins

Signed-off-by: Eduardo Apolinario <[email protected]>

Signed-off-by: Eduardo Apolinario <[email protected]>
Co-authored-by: Eduardo Apolinario <[email protected]>
  • Loading branch information
eapolinario and eapolinario authored Nov 30, 2022
1 parent f4ede35 commit b4a6a57
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ jobs:
run: rm -rf ./gen
- name: "Run buf generate"
run: buf generate
- name: "Include __init__.py files"
run: find gen/pb_python -type d -exec touch {}/__init__.py \;
- uses: actions/upload-artifact@master
with:
name: generated-buf
Expand Down
4 changes: 2 additions & 2 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ version: v1
managed:
enabled: true
plugins:
- remote: buf.build/grpc/plugins/python:v1.49.1-1
- remote: buf.build/grpc/plugins/python:v1.51.1-1
out: gen/pb_python
- remote: buf.build/protocolbuffers/plugins/python:v21.7.0-1
- remote: buf.build/protocolbuffers/plugins/python:v21.9.0-1
out: gen/pb_python
- remote: buf.build/protocolbuffers/plugins/pyi:v21.9.0-1
out: gen/pb_python
Empty file added gen/pb_python/__init__.py
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
7 changes: 7 additions & 0 deletions generate_protos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@ do
done

# Buf migration
# TODO: fix stub generation via docker image. The trick of forcing the current user as a user in
# the container (used extensively in this file) does not work.
# docker run --volume "$(pwd):/workspace" --workdir /workspace bufbuild/buf generate
buf generate

# Unfortunately the python protoc plugin does not add __init__.py files to the generated code
# (as described in https://github.com/protocolbuffers/protobuf/issues/881). One of the
# suggestions is to manually create such files, which is what we do here:
find gen/pb_python -type d -exec touch {}/__init__.py \;

# Docs generated

# Remove any currently generated core docs file
Expand Down
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
maintainer_email='[email protected]',
packages=find_packages('gen/pb_python'),
package_dir={'': 'gen/pb_python'},
# https://github.com/pypa/setuptools/issues/3136 describes an extension to
# setuptools that would involve a simpler way to specify this, but while
# that does not happen we have to package the pyi files manually like so:
package_data={'flyteidl': ["*.pyi", "**/*.pyi"]},
dependency_links=[],
install_requires=[
'googleapis-common-protos',
Expand Down

0 comments on commit b4a6a57

Please sign in to comment.