full-author-61014
04/30/2024, 7:43 AMadhoc_tool
. How can I tell pants I want to build a pex from the pyarmor output and set an entry point. pants (rightfully) complains about duplicates IntrinsicError: Can only merge Directories with no duplicates, but found 2 duplicate entries in ...
. I tried to introduce a parent package in the pyarmor output. That basically works, but breaks absolute import statements in the original code in the distributed pex. It also needs a source root for the new parent package (which does only appear as adhoc_tool output), so not ideal. Any elegant ideas?square-psychiatrist-19087
04/30/2024, 8:14 AMs/from mypackage/from gen_mypackage/
and proceed with your idea about parent packagefull-author-61014
04/30/2024, 12:12 PMentry_point
in the pex_binary
, it picks the original code, not the adhoc_tool output from pyarmor. However when I use the executable
field and point to a py file, it will package the pyarmor output. This is confusing. I guess pants will infer the first dependency it finds for a given entry_point
and pull in all those dependencies. Does not do that however for executable
mode.full-author-61014
04/30/2024, 12:14 PMpython_distribution
from the pyarmor output which does not have a resolve field. python_distribution
does not have a resolve
field, so this won't work.square-psychiatrist-19087
04/30/2024, 12:21 PMadhoc_tool(
name="main.py",
execution_dependencies=["//src/python/mypackage:main.py"],
output_files=["//generated/mypackage/main.py"],
)
experimental_wrap_as_python_sources(
name="gen_main.py",
inputs=[":main.py"],
)
python_distribution(name="dist", dependencies=[":gen_main.py"])
square-psychiatrist-19087
04/30/2024, 12:24 PMnot the adhoc_tool output from pyarmoryou're probably not wrapping adhoc_tool as python sources, which means all the machinery for pex_binary won't work
full-author-61014
04/30/2024, 12:27 PMentry_point
in the python_distribution
such as
python_distribution(
name="dist",
dependencies=[":gen_main.py"]
entry_points={
"console_scripts": {"cli": "mypackage.main:main"},
},
Then pants will add the dependency for mypackage.main from the original files. It will produce the error I stated at the beginning about duplicate files. I think I will need to provide a full example.square-psychiatrist-19087
04/30/2024, 12:31 PM