Pants exclude specific Python dependencies

739 Views Asked by At

Currently, I am using pants to build and test our python2.7 packages. We started noticing the following error during run goal after pytests goal is completed. I tried adding constraints.txt file to exclude the dependencies its complaining about, but the error wouldn't stop. Is there a way to exclude these dependencies during the pants build step?

./pants test.pytest --coverage=auto tests/python/abcd/test/xyz 

[pytest]
[cache] 
No cached artifacts for 1 target.
Invalidated 1 target.
[run]
Failed to execute PEX file, missing compatible dependencies for:
 importlib-metadata
 zipp

No .coverage file was found! Skipping coverage reporting.
                   tests/python/abcd/test/xyz                                      .....   SUCCESS

FAILURE
1

There are 1 best solutions below

4
Jordan Gillard On

Can you try increasing the verbosity with:

PEX_VERBOSE=9 ./pants test.pytest --coverage=auto tests/python/abcd/test/xyz

and then respond here?

This error can be caused by a couple of things. Are you executing the PEX on the same operating system that the PEX was built on? Do you also include platforms=[...] in your python_binary function in your BUILD file?