stocky-engine-79940
11/01/2020, 8:35 PMhundreds-father-404
11/01/2020, 8:55 PMgen
goal because we don’t want people to think they must manually run that goal for codegen to work. We can add it, only wanted to wait for user need
Also, to clarify, the generated files get used everywhere, including running tests. That tip in the docs about building a Pex to inspect the generated files is solely a workaround to be able to see them, because we don’t have that gen
goalstocky-engine-79940
11/02/2020, 10:36 AMstocky-engine-79940
11/02/2020, 10:37 AMhundreds-father-404
11/02/2020, 2:06 PMgen
. Maybe write-codegen
? We want to make it abundantly clear that you never need to run this goal for things to work, it’s only if you want to save the files to your build rootwitty-crayon-22786
11/02/2020, 5:45 PMhundreds-father-404
11/02/2020, 8:13 PMstocky-engine-79940
11/03/2020, 8:16 AMimport pdb; pdb.set_trace()
. I suppose they can do that (probably?) using the repl
command but it seems like it adds a layer of indirection.stocky-engine-79940
11/03/2020, 8:21 AMwitty-crayon-22786
11/03/2020, 6:37 PMrepl
, run
, or test --debug
witty-crayon-22786
11/03/2020, 6:38 PMtest
defaults to the background without debug)witty-crayon-22786
11/03/2020, 6:41 PMwitty-crayon-22786
11/03/2020, 6:42 PMstocky-engine-79940
11/04/2020, 10:11 AMworkon
we manipulate the python path and do a bunch of other things to load various scripts etc…). My impression is that virtualenvs are the closest thing to a lowest common denominator across all the editors we’re using and in our project setup so making it easy to, for example, automatically load all the source roots into the python path is probably something I would end up adding to our environment bootstrap script so that imports could cleanly map to how they would be structured in the generated pexs. I am not sure if thats a universal way people want to interact with their dev environment though so I’ll be more than willing to upstream any changes but it may not solve a problem for everyone. For me personally, a pycharm integration be nice but not certainly not a deal breaker. Getting it to work with a pex seems like it could be challenge…I don’t know if pycharm supports a concept of sourcemapping or anything like that.witty-crayon-22786
11/04/2020, 8:49 PMwitty-crayon-22786
11/04/2020, 8:50 PMhundreds-father-404
11/05/2020, 3:07 AMwrite-codegen
goal, which writes the files to the same place they end up actually being generated when used by Pants.
I could see one thing being a big issue and being confusing: if those Python files are generated in the same folder where you have a python_library()
with the default sources field, then Pants will think that those generated files are your own and like normal Python files. If dep inference is used, it would result in those checked-in files being used, but Pants still attempting to do codegen; this could result in a merge conflict if the checked-in conflicts are stale, which results in an exception.
Two solutions, I think:
1. Keep writing to the build root, but detect somehow if those files aren’t covered by pants_ignore
/ gitignore
. If they aren’t ignored, then log a warning and strongly encourage ignoring them.
2. Always write to the dist/
folder instead, which should never have a BUILD
file and is always ignored by Pants.
I think #2 is simpler. Omar, would that be fine if we write the files like this, with the dist/
prefix: dist/src/python/project/util/my_file_pb2.py
? Keep in mind that that folder is usually gitignored - not sure if that would be an issue for IDEswitty-crayon-22786
11/05/2020, 6:30 PMhappy-kitchen-89482
11/05/2020, 10:51 PMdist/codegen/src/python/project/util/my_file_pb2.py
stocky-engine-79940
11/06/2020, 6:41 AMstocky-engine-79940
11/06/2020, 6:42 AMhundreds-father-404
11/06/2020, 5:51 PMwrite-codegen
goal. Feedback welcomed on the two questions posed in comments:
1) if that’s a good goal name
2) whether we should only activate if you’re using Protobuf
https://github.com/pantsbuild/pants/pull/11107witty-crayon-22786
11/06/2020, 6:14 PMhundreds-father-404
11/06/2020, 8:48 PMexport-codegen
as a more light weight option. Totally feasible for it to be ./pants export --codegen-only
for examplewitty-crayon-22786
11/06/2020, 8:54 PMTotally feasible for it to beyea, that might be a reasonable directionfor example./pants export --codegen-only
hundreds-father-404
11/10/2020, 3:01 AMexport-codegen
rule. See https://www.pantsbuild.org/v2.1/docs/upgrade-tips for tips with upgrading, and https://www.pantsbuild.org/v2.1/docs/release-notes-2-1 for a changelog