-
Notifications
You must be signed in to change notification settings - Fork 72
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 python bindings for protobufs #172
Add python bindings for protobufs #172
Conversation
Thanks for this PR @chasen-bettinger ! I ran the We definitely don't want a hack. I'm thinking we might have to change the directory structure for the protobufs. @TomHennen any ideas? |
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.
Thanks! I'm also realizing a few other obstacles. (1) The __init__.py
files are needed at a minimum to make this a proper python package. We probably also want a setup.py
file to actually allow installs. (2) The package base name io.in_toto.attestation
isn't preserved for the Python bindings right now. I think that's related to our current directory structure (per #172 (comment)).
Side note: let's use a pyproject.toml file rather than setup.py. |
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.
Thanks for doing this!
I think we definitely need the Makefile rule.
As for the generated code, we had checked in the go stubs because it's pretty standard for go code to check that stuff in directly (and it's how go can find the stuff IIUC).
For other languages (like Python) I wonder if it would be preferable to publish a package to PyPI?
Consider this optional. I'll defer to others.
I think we will want to but we have to be mindful of the interplay with https://pypi.org/project/in-toto/. The other alternative is to store generated py files in in-toto/in-toto but I don't like the sound of that... |
Perhaps an in-toto-attestations package in-toto/in-toto uses as a dependency is fine. @lukpueh wdyt? |
I was thinking about this too. Would it make sense to have an |
FWIW, the sources for the protobuf python package live in the same repo as the protos. I wonder if we could have a setup similar to them. Also, to have a consistent package structure for a language bindings in the future, I recommend we move the protos to a separate directory structure: |
Note: I'm not necessarily proficient with Python packaging. My understanding is PyPI doesn't support namespaces like NPM does. To have it be IMO, we should make |
I feared as much.
Completely agree. I think there'd be a way to use Python's namespace packages when building and deploying a single |
@chasen-bettinger We just merged #180. Could you please rebase your branch and regenerate the python bindings given the new directory structure? If you could please update the Makefiles (there's a top-level and one in protos now), that would be really helpful! |
- Added Makefile command to generate these bindings - Ran into trouble with the folder path not being preserved. You'll notice that the generated files are in v1/0 instead of the to-be expected v1.0/. That is not intentional, but I'm not sure how to correct this without implementing a hack. Signed-off-by: Chasen Bettinger <bettingerchasen@gmail.com>
09cf039
to
8c60a55
Compare
Additionally, include the python bindings that were created from the exeuction of that Makefile command. Signed-off-by: Chasen Bettinger <bettingerchasen@gmail.com>
@marcelamelara Thanks for the update. Ready for your re-review! |
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.
Thanks @chasen-bettinger ! I have a few minors changes.
- Add make command for python bindings in primary Makefile - Retain new line in primary Makefile - Adjust Makefile in protos directory such that the python bindings do not use the -I flag because of the intended directory structure and the python target was added to .PHONY. Signed-off-by: Chasen Bettinger <bettingerchasen@gmail.com>
@marcelamelara Tag, you're 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.
Thanks @chasen-bettinger !! LGTM :) This sets us up really nicely to get the python package released!
@adityasaky @TomHennen I figure we can update the documentation separately when this PR is merged and we're done setting up everything else we need to release to PyPI? |
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.
Thanks @chasen-bettinger!
Will merge after #192 is merged. |
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.
Thanks!
This closes #171 .