https://pantsbuild.org/ logo
#general
Title
# general
g

gentle-painting-24549

11/29/2022, 5:17 PM
I’ve got an issue with an undeclared dependency inside Python tests. I’ve got a test with a dependency that uses an underlying C++ Package: GDCM. Before pants we would perform a
conda install gdcm
inside of tox to run our tests. Without having access to Conda an alternative I’ve found is to use
python-gdcm
instead which is a Python wrapper for GDCM. I’ve tried to attach this dependency to the tests using a `python_requirement`:
Copy code
python_requirement(
    name="gdcm",
    requirements=["python-gdcm"],
)

python_tests(
    name="tests",
    sources=[
        "tests/**/test_*.py",
        "tests/test_*.py",
    ],
    dependencies=[
        ":conftest",
        ":test-resources",
        ":gdcm",
    ],
)
However this doesn’t work and
python-gdcm
doesn’t get installed into the underlying testing PEXs unless I add this snippet to one of my test files:
Copy code
try:
    import gdcm # noqa
except ImportError:
    pass
How can I have the tests depend on
python-gdcm
without the attempted import? Or alternatively, how can I give Pants access to the underlying gdcm binary (for example, one that was installed by brew or conda on the host system)?
6 Views