brainy-solstice-27042
03/30/2023, 5:56 PMscript
tag in my build file for the pex binary then pants complains that it cannot find the file that's in the same directory as the build file. If I use the entry_point
tag I get an import error saying there was no module main found. I'l curious to see what I could be doing wrongbrainy-solstice-27042
03/30/2023, 6:02 PMenough-analyst-54434
03/30/2023, 6:11 PMscript
field is for console scripts - those are generally only defined in a packaged wheel via entry_points.txt metadata. Like so for the cowsay
wheel:
$ cat /home/jsirois/.pex/installed_wheels/0b005324b3bd9c50d9214dfd38a39e4bf4522635e32bec351d7dfcd4c9e3e6e2/cowsay-5.0-py2.py3-none-any.whl/cows
ay-5.0.dist-info/entry_points.txt
[console_scripts]
cowsay = cowsay.main:cli
That is likely not what you mean.enough-analyst-54434
03/30/2023, 6:12 PMentry_point
field, please dump your BUILD here if possible.enough-analyst-54434
03/30/2023, 6:16 PMbrainy-solstice-27042
03/30/2023, 6:19 PMenough-analyst-54434
03/30/2023, 6:20 PMbrainy-solstice-27042
03/30/2023, 6:23 PMImportError: No module named main
enough-analyst-54434
03/30/2023, 6:28 PMpython_source(name="main", source="main.py")
and then add a dep on that in the pex_binary
target.enough-analyst-54434
03/30/2023, 6:29 PMenough-analyst-54434
03/30/2023, 6:29 PMenough-analyst-54434
03/30/2023, 6:30 PMbrainy-solstice-27042
03/30/2023, 6:31 PMenough-analyst-54434
03/30/2023, 6:32 PMpython_sources()
pex_binary(name="shorts", entry_point="main.py:runner")
And all the rest would be done for you assuming main.py tranisitively imported all the rest and all the rest had BUILD files with python_source(s) targets owning them.enough-analyst-54434
03/30/2023, 6:34 PMpants tailor
, that's new and deals with populating these ~empty BUILD targets. Pants can infer most things now, but it still - weirdly - needs empty targets at least to own files. Pure legacy weirdness.
+ https://www.pantsbuild.org/docs/reference-tailor
+ https://www.pantsbuild.org/docs/initial-configuration#generate-build-filesenough-analyst-54434
03/30/2023, 6:35 PMpants tailor ::
, then adjust.enough-analyst-54434
03/30/2023, 6:35 PMbrainy-solstice-27042
03/30/2023, 6:36 PMbrainy-solstice-27042
03/30/2023, 6:37 PMenough-analyst-54434
03/30/2023, 6:39 PMprint(...)
to main.py and then provide full output for pants run ...
assuming that's the goal you are running here. If not and it's pants package ... && ./dist/shorts.pex
- then same.enough-analyst-54434
03/30/2023, 6:41 PMIf it's helpful, the cli uses an async main method as wellYou'll have to excuse my ignorance. I thought you needed a normal main entry point that started an event loop to then get into async-land. Perhaps revealing as much of the main.py as you can would be helpful.
brainy-solstice-27042
03/30/2023, 6:47 PMenough-analyst-54434
03/30/2023, 6:49 PMbrainy-solstice-27042
03/30/2023, 6:55 PMenough-analyst-54434
03/30/2023, 7:01 PM