dry-forest-42241
06/06/2023, 9:10 PMpex_binaries
and python_distribution
targets in all projects using a macro. Before adding python_distribution
, pants repl
used to work fine. After adding python_distribution
, we are seeing a resolve error
pex.environment.ResolveError: Failed to resolve requirements from PEX environment @ /path/to/.cache/pants/named_caches/pex_root/unzipped_pexes/d5bb451b67b4592376d4f6e8dde708facaf22sf7.
Needed cp39-cp39-manylinux_2_31_x86_64 compatible dependencies for:
1: project-c==0.0.1
Required by:
project-a 0.0.1
But this pex had no ProjectName(raw='project-c', normalized='project-c') distributions.
2: numpy>=1.24.0
Required by:
project-a 0.0.1
But this pex had no ProjectName(raw='numpy', normalized='numpy') distributions.
A couple of questions:
1. When only using pex_binaries
, the repl command works fine but when adding python_distribution
it breaks. Why is this happening?
2. numpy is a direct dependency added in the dependencies
field in python_distribution
and project-c
should be an inferred dependency from the code. Why is it not resolving these dependencies? I verified they were added successfully to the wheel file.
Thanks
Edit: we are using pants 2.16.0rc4happy-kitchen-89482
06/06/2023, 9:35 PMhappy-kitchen-89482
06/06/2023, 9:37 PMbroad-processor-92400
06/06/2023, 9:47 PMpython_distribution
is only needed when it's an external artifact (e.g. publishing wheels), rather than for consumption within the repo by `pex_binary`ies etc.?happy-kitchen-89482
06/06/2023, 10:04 PMdry-orange-3870
06/06/2023, 10:11 PMpython_distribution
defined so we can build wheels for pushing to our artifact store.
We use pex
for things like that whole "run our code on a remote host" thing I outlined here.dry-orange-3870
06/09/2023, 2:14 PMPants cannot infer owners for the following imports in the target ...
* numpy (line: 3)
and earlier in the logs, it complains like so:
imports `numpy`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use
We have multiple directories with their own BUILD files. Each of these directories has a requirements.txt
file defined with a corresponding python_requirements
target. Is it problematic if multiple requirements.txt
files specify the same dependency? Does that prevent dependency inference from working properly?happy-kitchen-89482
06/09/2023, 8:07 PMhappy-kitchen-89482
06/09/2023, 8:07 PMhappy-kitchen-89482
06/09/2023, 8:08 PMnumpy
package, and pants doesn't know which one to selecthappy-kitchen-89482
06/09/2023, 8:08 PMhappy-kitchen-89482
06/09/2023, 8:08 PMhappy-kitchen-89482
06/09/2023, 8:09 PMhappy-kitchen-89482
06/09/2023, 8:12 PMhappy-kitchen-89482
06/09/2023, 8:12 PMdry-orange-3870
06/12/2023, 12:40 PM.
āāā locks
ā āāā real_stuff.lock.jsonc (numpy 1.25)
ā āāā pants-plugins.lock.jsonc
ā āāā resolve_example_1.lock.jsonc (numpy 1.23)
ā āāā resolve_example_2.lock.jsonc (numpy 1.24)
āāā pants-plugins
ā āāā BUILD
ā āāā plugin_1
ā ā āāā rules.py
ā ā āāā register.py
ā āāā plugin_2
ā ā āāā register.py
ā ā āāā rules.py
ā āāā macros.py
āāā pants.toml
āāā projects
ā āāā examples
ā ā āāā example_project_1
ā ā ā āāā BUILD (resolve=resolve_example_1)
ā ā ā āāā example_project_1
ā ā ā ā āāā f1.py (imports example_util_library.sample)
ā ā ā āāā requirements.txt (numpy < 1.24)
ā ā āāā example_project_2
ā ā ā āāā BUILD (resolve=resolve_example_2)
ā ā ā āāā example_project_2
ā ā ā ā āāā f2.py (imports example_util_library.sample)
ā ā ā āāā requirements.txt (numpy >= 1.24)
ā ā āāā example_util_library
ā ā āāā BUILD (resolves=[resolve_example_1, resolve_example_2])
ā ā āāā example_util_library
ā ā ā āāā sample.py (imports numpy)
ā ā āāā requirements.txt (numpy < 1.25)
ā āāā real_stuff
ā āāā groceries
ā ā āāā shopping
ā ā āāā BUILD (resolve=real_stuff)
ā ā āāā requirements.txt
ā ā āāā shopping
ā ā ā āāā buy.py (references grocery_utils.make_a_list)
ā ā āāā grocery_utils (resolve=real_stuff)
ā ā āāā BUILD
ā ā āāā requirements.txt (numpy)
ā ā āāā grocery_utils
ā ā ā āāā make_a_list.py (imports numpy)
āāā pyproject.toml
Things seem to be working fine for the two "example" resolves, but maybe that's just because all three BUILD files specify something about numpy
?
For the real_stuff
resolve, shopping
references grocery_utils
, but doesn't know about numpy. At runtime though, when invoking make_a_list
, things fail because the numpy dependency isn't inferred. For now, we've worked around this by adding an explicit entry in our python_sources
dependencies list to point to the python_requirements
in the same BUILD
file. This allows us to keep moving forward, but isn't ideal as every source file in a python_sources
now depends on every line in a requirements.txt
which will lead to more cache-misses even when that's not actually necessaryhappy-kitchen-89482
06/12/2023, 2:37 PMhappy-kitchen-89482
06/12/2023, 2:40 PMpants roots
to see them.dry-orange-3870
06/12/2023, 2:43 PM.
pants-plugins
projects/examples/example_project_1
projects/examples/example_project_2
projects/examples/example_util_library
projects/real_stuff/groceries/shopping
projects/real_stuff/groceries/grocery_utils