quaint-telephone-89068
02/08/2023, 1:46 AMpython_sources() without a name
2. the entry point of multiple `pex_binary`s (this happens in practice with docker builds https://blog.pantsbuild.org/optimizing-python-docker-deploys-using-pants/, one PEX with include_sources=False, include_requirements=True and one with the include_sources=True, include_requirements=False)
# dir/BUILD
python_sources()
pex_binary(name="pex1", entry_point="x.py")
pex_binary(name="pex2", entry_point="x.py")
running that Python file directly is awkward: pants run dir/x.py complaints and lists out the original dir/x.py input as a "better" target to choose from:
TooManyTargetsException: The `run` goal only works with one valid target, but was given multiple valid targets:
* dir/x.py
* dir:pex1
* dir:pex2
Please select one of these targets to run.
The correct way to run it is pants run dir/x.py:dir. The first line of the error message should thus say dir/x.py:dir instead of dir/x.py. (If the python_sources is given an explicit name, e.g. name="dir", the error message is fine.)
Reproducer: https://gist.github.com/huonw/73b947b318b115a298f0bcf57e6a0d51
git clone <https://gist.github.com/73b947b318b115a298f0bcf57e6a0d51.git>
cd 73b947b318b115a298f0bcf57e6a0d51
./run.sh
Pants version
2.14.0, 2.15.0rc3, 2.16.0.dev6
OS
macOS
Additional info
https://gist.github.com/huonw/73b947b318b115a298f0bcf57e6a0d51
pantsbuild/pants