pantsbuild / pants

The Pants Build System
https://www.pantsbuild.org
Apache License 2.0
3.27k stars 626 forks source link

Failed to resolve requirements from PEX environment #18242

Closed Peder2911 closed 1 year ago

Peder2911 commented 1 year ago

Pants fails to install requirements for my library with the following message:

Failed to resolve requirements from PEX environment @ /root/.cache/pants/named_caches/pex_root/unzipped_pexes/03edf50c1d8897371819584d4094814692505ea8.
Needed {{ ENVIRONMENT }} compatible dependencies for:

 1: {{ requirement_name }}
    Required by:
      {{ my_package }}
    But this pex had no ProjectName(raw='{{ requirement_name }}', normalized='{{ requirement_name }}') distributions.
...

I have tried several environments (Linux ARM, M1 Mac, x86_64 Linux).

The command that fails is the equivalent of ./pants test ./libs/my_package/tests/test_something.py. The BUILD file located in libs/my_package looks like this:

python_sources(
   name = "lib",
)

python_requirements(
   name = "req",
)

python_distribution(
   name = "pkg",
   provides = python_artifact(
      name = "my_library_name",
      version = "0.0.0",
   ),
   dependencies = [
      ":lib",
      ":req",
   ]
)

python_tests(
   name = "tests",
   sources= ["./tests/*"],
   dependencies = [
      ":pkg"
   ],
)

The issue appears for a library with a large set of requirements:

aiohttp~=3.8.3
aiosignal~=1.2.0
anyio~=3.6.2
async-timeout~=4.0.2
atomicwrites~=1.4.1
attrs~=22.1.0
boltons~=21.0.0
brotli~=1.0.9
certifi~=2022.9.24
cffi~=1.15.1
charset-normalizer~=2.1.1
classes~=0.4.1
click~=8.1.3
colorama~=0.4.5
cryptography~=38.0.1
ecdsa~=0.18.0
environs~=9.5.0
face~=22.0.0
faker-commerce~=1.0.3
faker~=15.3.2
flatten-dict~=0.4.2
frozenlist~=1.3.1
furl~=2.1.3
glom~=22.1.0
idna~=3.4
iniconfig~=1.1.1
marshmallow~=3.18.0
msal~=1.20.0
multidict~=6.0.2
openapi-schema-pydantic~=1.2.4
orderedmultidict~=1.0.1
packaging~=21.3
pluggy~=1.0.0
py~=1.11.0
pyasn1~=0.4.8
pycparser~=2.21
pydantic~=1.10.2
pyjwt[crypto]~=2.6.0
pyparsing~=3.0.9
pytest-mock~=3.10.0
pytest~=7.1.2
python-dateutil~=2.8.2
python-dotenv~=0.21.0
python-jose~=3.3.0
redis~=4.3.5
requests~=2.28.1
returns~=0.19.0
rsa~=4.9
six~=1.16.0
sniffio~=1.3.0
starlette~=0.20.4
tabulate~=0.8.10
tomli~=1.2.3
toolz~=0.12.0
typing-extensions~=4.4.0
urllib3~=1.26.12
yarl~=1.8.1

Pants version My Pants version is 2.14.1.

OS I am encountering this issue on Mac and Linux.

Peder2911 commented 1 year ago

Working on a small reprex repository.

Peder2911 commented 1 year ago

Reprex here: https://github.com/Peder2911/pantsbuild_issue_reprex

This gives me the same error as before.

Peder2911 commented 1 year ago

Ah right, the issue is that I am taking a dependency on the package, not the sources when defining the test. Sorry, this has nothing to do with platform incompatibility.