-
Notifications
You must be signed in to change notification settings - Fork 1
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
Is there a working example of how to use this project anywhere? #16
Comments
We do use it in a multiple projects, although with the same input and output path. Take a look here: https://gitlab.nic.cz/fred/api/messenger (or any other project in the same group) As for setuptools picking up the generated modules, this may require setting I agree that it makes sense to add |
Just to be clear, if you would benefit from generating empty |
This is me attempting to follow the advice on CZ-NIC/setuptools-grpc#16 (comment), but this doesn't really work. First build doesn't work (note that there are no `module1_pb2.*` files): $ pip install . && pip show -f jfly Processing /home/jeremy/tmp/setuptools-grpc-demo Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: jfly Building wheel for jfly (pyproject.toml) ... done Created wheel for jfly: filename=jfly-0.0.1-py3-none-any.whl size=904 sha256=c7eed92a4897aca10015c53a8a81b552a36bb2b5629561a37643829907516819 Stored in directory: /home/jeremy/.cache/pip/wheels/94/3f/96/34cbbd64f469cfadb00e57c6f6651a098fe76c85f79dbb0e9c Successfully built jfly Installing collected packages: jfly Successfully installed jfly-0.0.1 [notice] A new release of pip is available: 23.2.1 -> 23.3.2 [notice] To update, run: pip install --upgrade pip Name: jfly Version: 0.0.1 Summary: Home-page: Author: Author-email: License: Location: /home/jeremy/tmp/setuptools-grpc-demo/.direnv/python-3.11/lib/python3.11/site-packages Requires: Required-by: Files: jfly-0.0.1.dist-info/INSTALLER jfly-0.0.1.dist-info/METADATA jfly-0.0.1.dist-info/RECORD jfly-0.0.1.dist-info/REQUESTED jfly-0.0.1.dist-info/WHEEL jfly-0.0.1.dist-info/direct_url.json jfly-0.0.1.dist-info/top_level.txt Second build *does* work (note that there are `module1_pb2.*` files): $ pip install . && pip show -f jfly Processing /home/jeremy/tmp/setuptools-grpc-demo Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: jfly Building wheel for jfly (pyproject.toml) ... done Created wheel for jfly: filename=jfly-0.0.1-py3-none-any.whl size=2905 sha256=45e70cd416572af4c4df2fa9d4b293f2df863ae46525b868a97ffd9900b75eba Stored in directory: /home/jeremy/.cache/pip/wheels/94/3f/96/34cbbd64f469cfadb00e57c6f6651a098fe76c85f79dbb0e9c Successfully built jfly Installing collected packages: jfly Attempting uninstall: jfly Found existing installation: jfly 0.0.1 Uninstalling jfly-0.0.1: Successfully uninstalled jfly-0.0.1 Successfully installed jfly-0.0.1 [notice] A new release of pip is available: 23.2.1 -> 23.3.2 [notice] To update, run: pip install --upgrade pip Name: jfly Version: 0.0.1 Summary: Home-page: Author: Author-email: License: Location: /home/jeremy/tmp/setuptools-grpc-demo/.direnv/python-3.11/lib/python3.11/site-packages Requires: Required-by: Files: jfly-0.0.1.dist-info/INSTALLER jfly-0.0.1.dist-info/METADATA jfly-0.0.1.dist-info/RECORD jfly-0.0.1.dist-info/REQUESTED jfly-0.0.1.dist-info/WHEEL jfly-0.0.1.dist-info/direct_url.json jfly-0.0.1.dist-info/top_level.txt out/foo/__pycache__/module1_pb2.cpython-311.pyc out/foo/__pycache__/module1_pb2_grpc.cpython-311.pyc out/foo/module1_pb2.py out/foo/module1_pb2.pyi out/foo/module1_pb2_grpc.py I haven't read all the relevant setuptools code yet, but I believe setuptools does its package autodiscovery (possibly during the `egg_info` command?) *before* invoking the `build` command, so on the first run, it doesn't find any packages, and on the second run (with the `output_path` already populated), it does discover the files. I briefly played with a couple of ideas: 1. Explicitly listing the packages. - This doesn't work: the `egg_info` command crashes complaining that these package directories don't exist in the `out` directory. 2. Trying to hook earlier into the build process (before the `egg_info` command). - This didn't immediately work. I don't know enough about the details of python packaging to know if this idea has legs.
Thanks for the info. I'm trying to put together an example with different input and output paths, and I can't get it to work. See https://github.com/jfly/setuptools-grpc-demo/tree/broken-different-proto-and-output-paths (in particular this commit message). Also here's a quick demo: Trying to install this in a fresh venv (`pip install 'jfly @ git+https://github.com/jfly/setuptools-grpc-demo.git@broken-different-proto-and-output-paths'`)
Note how there are no
Is this possible? From the experimentation I've been doing, it feels to me like the directory structure must be in place before |
So, first thing I see is that you need to add |
I usually use
However, this directory actually does exist. I'm not sure why setuptools don't recognize it, but we use |
OK, I get it now. The problem is that setup.cfg[options]
packages = find_namespace:
include_package_data = true
[build_grpc]
proto_files = **/*.proto
grpc_files = **/*.proto
proto_path = ./src
output_path = ./out MANIFEST.in
Now, as you said, the directory structure indeed has to be in place at the moment. |
I've been trying to follow the README, and have run into a couple of issues:
proto_path
andoutput_path
is to ensure that the generated files are included in a built wheel.The one example I've been able to find that uses
setuptools-grpc
is https://github.com/mlcommons/chakra, which chooses to setproto_path
andoutput_path
to the same thing, which is not something I'd have ever expected to do.I think a simple, working example of one correct way of using this tool would go a long way towards clearing up any confusion.
The text was updated successfully, but these errors were encountered: