refined-cat-61929
08/16/2024, 9:21 PM__init__.py
), or put all your protos in a root directory, not underneath any directory that's a module.
The issue is that protoc doesn't generate __init__.py
files, so any package in dist/codegen
under a module package (with the init file), cannot be found.
Has anyone hit upon any reasonable way to solve the problem? Forcing us into a package structure just to satisfy python module rules seems weird. Using namespace packages is also weird, and causes its own problems (frequently it means that pants test
doesn't work for something but pants run
does). It's hard to figure out a reasonable solution here.happy-kitchen-89482
08/17/2024, 9:43 PMdist/codegen
is just where Pants exports generated code when you ask it to. It doesn’t use that for pants test
, pants run
and so on.happy-kitchen-89482
08/17/2024, 9:43 PMcurved-manchester-66006
08/20/2024, 7:05 PMrefined-cat-61929
08/21/2024, 3:21 PMdist/codegent
doesn't have any __init__.py
, anything there that's namespaced within a package that does have __init_.py_
is not usable. One solution might be for Pants to create __init__.py
, which I think is technically possible, but it would break anyone using namespace packages, so it would have to be an option.
For example, if our regular code has package foo
, and we have a foo/protos
, then foo/protos
, then trying to import foo.protos
would only work in Pants. To be clear, this is not a Pants problem, but it could be that Pants could make this better. Or maybe just people have some standard way to deal with this.
@curved-manchester-66006 do you do this nesting of your proto packages?curved-manchester-66006
08/21/2024, 5:57 PMdo you do this nesting of your proto packages?The proto names are pretty "flat", so I dont' think you have a case of src / foo / some proto / bar / some python
refined-cat-61929
08/21/2024, 7:51 PMhappy-kitchen-89482
08/21/2024, 10:19 PM__init__.py
files, but I guess Pants could also do sorefined-cat-61929
08/22/2024, 12:51 AM