full-author-61014
03/13/2024, 9:44 AMpython_tests
that depends on a python_distribution
. I want to enable test cases to import classes/methods from my 1st level project, but not from source, but from the installed python_distribution
.
That's what tox does to expose packaging bugs. The code should just be on sys.path when running the tests.
However pants test
gives me
ProcessExecutionFailure: Process 'Building pytest_runner.pex' failed with exit code 1.
stdout:
stderr:
Failed to resolve requirements from PEX environment @ /tmp/pants-sandbox-TTd27y/local_dists.pex.
Needed cp311-cp311-manylinux_2_39_x86_64 compatible dependencies for:
1: sphinx>=5
Required by:
sphinx-ukc 0.1.0
But this pex had no ProjectName(raw='sphinx', validated=False, normalized='sphinx') distributions.
sphinx-ukc
is my 1st level source and it depends on sphinx
. I digged through the open and closed issues/PRs and found these
https://github.com/pantsbuild/pants/pull/12573 (Build and install python_distribution deps for test, run, and repl)
https://github.com/pantsbuild/pants/issues/15688 (Bug in dependency handling when python_test depends on python_distribution)
https://github.com/pantsbuild/pants/issues/15801 (Using python_distribution target as dependency does not honor the dependencies defined in install_requires in setup.py when creates pex_binary)
https://github.com/pantsbuild/pants/issues/15543 (Run tests on (sub)projects that are actually installed, not just against their source)
It looks like pants does not inject 3rd level dependencies when depending on a python_distribution
. Adding the missing transitive dependencies to the python_tests
dependencies as outlined here does not fix the problem.
Using https://www.pantsbuild.org/2.18/reference/targets/python_tests#runtime_package_dependencies does not solve my issue either, as I cannot import directly from an sdist or wheel that's put to the sandbox.
So my question is, whether my use case is supported or whether someone knows a workaround for this issue.
I don't want to use tox as a secondary tool.