gentle-painting-24549
12/06/2022, 6:23 PMpackage-1
has a Pyrex file (foo.pyx
) that gets compiled to a C Extension (foo.c
) at build time. The issue that I’m having is with plain Python projects in the monorepo that depend on that module. So in package-2
the following import raises an error, from package_1.foo import bar
.
My current workaround has been to create multiple resolves so that package-1
is actually a third party dependency for package-2
and the from package_1.foo import bar
statement passes as expected.
But I don’t really like that solution and now I’m stuck with an issue where in order to make a change to both package-1
and package-2
I have to go through the burdensome process of changing package-1
and republishing it and then changing package-2
.
Is there any pants magic that will allow me to keep both of these projects using the same resolve (i.e. package-2
depends on the compiled package-1
instead of the uncompiled code)?broad-processor-92400
12/06/2022, 9:18 PMgentle-painting-24549
12/06/2022, 10:02 PMprotobuf_sources
generates) they still won’t be recognized as valid sources during dependency inference without some custom work.happy-kitchen-89482
12/07/2022, 12:06 AMhappy-kitchen-89482
12/07/2022, 12:06 AMhappy-kitchen-89482
12/07/2022, 12:07 AMpython_sources
target to the python_distribution
target for package-1
, then Pants should do the right thinghappy-kitchen-89482
12/07/2022, 12:08 AMhappy-kitchen-89482
12/07/2022, 12:09 AMpython_distribution
into dists, and put them on the syspath in the right wayhappy-kitchen-89482
12/07/2022, 12:09 AMgentle-painting-24549
12/07/2022, 12:10 AMgentle-painting-24549
12/07/2022, 1:09 AM"pex had no ProjectName(raw='<package>', normalized='<package>') distributions."
for the third party dependencies.
❯ ./pants test packages/package-1:: --no-local-cache --no-pantsd
...
17:55:08.16 [WARN] Pants cannot infer owners for the following imports in the target packages/package-1/tests/test_foo.py:../tests:
* package_1.foo.bar (line: 1)
...
17:55:19.11 [ERROR] 1 Exception encountered:
ProcessExecutionFailure: Process 'Building pytest_runner.pex' failed with exit code 1.
stdout:
stderr:
Failed to resolve requirements from PEX environment @ /Users/justinflannery/.cache/pants/named_caches/pex_root/unzipped_pexes/bc2695fa37a2506cb61b51a40f9ca033f533b9f3.
Needed cp37-cp37m-macosx_12_0_x86_64 compatible dependencies for:
1: numpy<2,>=1
Required by:
package-1 0.1.0
But this pex had no ProjectName(raw='numpy', normalized='numpy') distributions.
2: scipy<2,>=1
Required by:
package-1 0.1.0
But this pex had no ProjectName(raw='scipy', normalized='scipy') distributions.
❯ ./pants test packages/package-2:: --no-local-cache --no-pantsd
...
17:56:56.93 [WARN] Pants cannot infer owners for the following imports in the target packages/package-2/package_2/baz.py:../lib:
* package_1.foo.bar (line: 4)
...
17:57:07.98 [ERROR] 1 Exception encountered:
ProcessExecutionFailure: Process 'Building pytest_runner.pex' failed with exit code 1.
stdout:
stderr:
Failed to resolve requirements from PEX environment @ /Users/justinflannery/.cache/pants/named_caches/pex_root/unzipped_pexes/43795547cf6eb6dc875955ce70c7c472da2f57be.
Needed cp37-cp37m-macosx_12_0_x86_64 compatible dependencies for:
1: numpy<2,>=1
Required by:
package-1 0.1.0
package-2 0.1.0
But this pex had no ProjectName(raw='numpy', normalized='numpy') distributions.
2: scipy<2,>=1
Required by:
package-1 0.1.0
package-2 0.1.0
But this pex had no ProjectName(raw='scipy', normalized='scipy') distributions.
gentle-painting-24549
12/07/2022, 1:48 AMhappy-kitchen-89482
12/07/2022, 7:27 AM./pants roots
show?happy-kitchen-89482
12/07/2022, 7:28 AMgentle-painting-24549
12/07/2022, 5:01 PM./pants roots
shows:
3rdparty
packages/package-1
packages/package-2
I think the dependency inference issue is that package_1.foo.bar
is defined in a .pyx
file and not a .py
file - so its target is a resource and not a python_source
. It doesn’t become an importable C
file until the dist is built and the file is compiled.
I am using a LockFile. The issues with the third party resources don’t show up until I add the dist
as a dependency on elements like tests.