Open ghost opened 2 years ago
I haven't used pipx
myself, I'll try to reproduce. I suspect pipx inject
installs the package in the virtualenv differently to what adding it via poetry does
Hi @Elijahh177, apologies for the long delay. I've installed both poetry and the plugin using pipx
and it's working as expected for me. Can you share more details on how your (virtual)environment is set up? I'm currently unable to reproduce.
Thanks
Hey @fedej, It seems that the following lines are not triggered correctly:
When I'm adding the protoc-gen-mypy
executable manually to the system path, everything is working fine.
I would provide more information, but didn't found a way to debug poetry plugins with VSCode.
I've reinstalled poetry
and reinstalled the plugin with poetry self add poetry-grpc-plugin
and the same error message appears.
@fedej do you know a way to attach the VSCode debugger to the poetry
resp. poetry-grpc-plugin
process?
I'm not using VSCode, so I'm not aware of how that works. I have some free time later on today and will check VSCode out as well as why that piece of code is not executing. As an alternative to debugging, and a good idea in general, I can add more debug logging to improve troubleshooting.
@Elijahh177 I wasn't able to find a clean way to debug directly from VSCode. The only thing that worked is manually adding breakpoints to the python files from the poetry environment.
I've added a few more logging statements and created a new release. These logs should show up with -vvv
e.g: poetry -vvv update
or poetry -vvv protoc
Let me know if that doesn't help
@Elijahh177 is this still a problem?
FWIW, I am in windows and faced the same problem. Tested with -vvv and verified that the virtualenv was being added correctly to the PATH, nonetheless protoc.main still wasn't picking protoc-gen-mypy.
What worked was to run poetry run poetry update
, which added the virtualenv path earlier.
@Elijahh177 is this still a problem?
Yes it's still a problem.
@fedej I switched my projects to PDM, since it allows for much easier user scripting.
You just have to add something like this to your pyproject.toml
and your *.proto
files will compile after every install:
[tool.pdm.dev-dependencies]
dev = [
"grpcio-tools>=1.54.2",
]
[tool.pdm.scripts]
post_install = "python -m grpc_tools.protoc --proto_path=src --python_out=src --pyi_out=src --grpc_python_out=src src/path/to/proto/interface.proto"
@fedej I switched my projects to PDM, since it allows for much easier user scripting.
You just have to add something like this to your
pyproject.toml
and your*.proto
files will compile after every install:[tool.pdm.dev-dependencies] dev = [ "grpcio-tools>=1.54.2", ] [tool.pdm.scripts] post_install = "python -m grpc_tools.protoc --proto_path=src --python_out=src --pyi_out=src --grpc_python_out=src src/path/to/proto/interface.proto"
@Elijahh177 I'm glad you were able to unblock yourself.
At this point it may be too little too late, but I changed how the plugin adds to stuff to PATH and I believe the problem should be fixed now. I'll release a new version shortly.
Invoking the protoc compiler results in the following error:
The command "protoc-gen-mypy" is either misspelled or could not be found. --mypy_out: protoc-gen-mypy: Plugin failed with status code 1.
This happens for both the "poetry protoc" as well as the "poetry update" (in combination with the "[tool.poetry-grpc-plugin]" table) commands.
I installed poetry with pipx and added poetry-grpc-plugin via
pipx inject
.My System: