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

aloof-appointment-30987

12/14/2022, 6:10 PM
Given the following BUILD file in my repo
./nectl/neuroedge_cli/BUILD
Copy code
python_sources(name = "neuroedge_cli")

pex_binary(
    name = "nectl",
    dependencies = [":neuroedge_cli"],
    entry_point = "./nectl.py",
)
If I run
Copy code
./pants run nectl/neuroedge_cli/nectl.py
Everything is fine. If I instead run
Copy code
./pants run nectl/neuroedge_cli:nectl
It fails with:
Copy code
12:58:13.40 [ERROR] 1 Exception encountered:

  ProcessExecutionFailure: Process 'Building nectl.neuroedge_cli/nectl.pex with 10 requirements: click==8.1.3, dvg-ringbuffer==1.0.3, keyring==23.5.1, numba==0.56.0, numpy==1.22.4, pandas~=1.4, requests==2.25.1, rich==12.4.1, scipy==1.8.1, tables==3.7.0' failed with exit code 1.
stdout:

stderr:
pid 28706 -> /Users/russellzarse/.cache/pants/named_caches/pex_root/venvs/cac1718c056bb509f51fcdcc0c376b33deaaa8ec/e6831f8bef1e0125d178dbca2c603370d4eeae8a/bin/python -sE /Users/russellzarse/.cache/pants/named_caches/pex_root/venvs/cac1718c056bb509f51fcdcc0c376b33deaaa8ec/e6831f8bef1e0125d178dbca2c603370d4eeae8a/pex --disable-pip-version-check --no-python-version-warning --exists-action a --no-input --isolated -q --cache-dir /Users/russellzarse/.cache/pants/named_caches/pex_root/pip_cache --log /private/var/folders/_d/zt8y2x055597l63bhdztp82c0000gn/T/pants-sandbox-8W6RvT/.tmp/pex-pip-log.ooax9v3d/pip.log download --dest /Users/russellzarse/.cache/pants/named_caches/pex_root/downloads/resolver_download.hetwm61n/usr.local.Cellar.python@3.11.3.11.0.Frameworks.Python.framework.Versions.3.11.bin.python3.11 click==8.1.3 dvg-ringbuffer==1.0.3 keyring==23.5.1 numba==0.56.0 numpy==1.22.4 pandas~=1.4 requests==2.25.1 rich==12.4.1 scipy==1.8.1 tables==3.7.0 --index-url <https://pypi.org/simple/> --retries 5 --timeout 15 exited with 1 and STDERR:
WARNING: Discarding <https://files.pythonhosted.org/packages/b3/23/fd8e7aa70f6c0b41c99de6aae7afc6850ebac2477687e68c6529bfaa41ba/numba-0.56.0.tar.gz#sha256=87a647dd4b8fce389869ff71f117732de9a519fe07663d9a02d75724eb8e244d> (from <https://pypi.org/simple/numba/>) (requires-python:>=3.7). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement numba==0.56.0
ERROR: No matching distribution found for numba==0.56.0
If I add
interpreter_constraints
to the
pex_binary
target
Copy code
pex_binary(
    name = "nectl",
    interpreter_constraints=['CPython==3.8.*'],
    dependencies = [":neuroedge_cli"],
    entry_point = "./nectl.py",
)
run succeed. However...
Copy code
pex_binary(
    name = "nectl",
    interpreter_constraints=['CPython>=3.8,<4'],
    dependencies = [":neuroedge_cli"],
    entry_point = "./nectl.py",
)
fails in the same way Why does the pex_binary require explicit constraints? Shouldn't the
CPython>=3.8,<4
configuration work?
h

hundreds-father-404

12/14/2022, 6:12 PM
Hello! What is
[python].interpreter_constraints
set to? Likely the difference is that
run
on a
python_source
target (the file argument) only uses a single interpreter. Whereas
neuroedge_cli:nectl
first builds the PEX you'd get from
./pants package
, then runs it -- those PEXes are built to work with every interpreter constraint you claim it can work with, e.g. 3.8, 3.9, 3.10
a

aloof-appointment-30987

12/14/2022, 6:13 PM
At the moment it is the default (not set). I had tried
Copy code
[python]
interpreter_constraints = ["CPython~=3.8"]
without success
h

hundreds-father-404

12/14/2022, 6:14 PM
hmm I'm surprised that setting it explicitly didn't fix it. What if you set it explicitly to
Python>=3.8,<4'
like you had in the BUILD file?
a

aloof-appointment-30987

12/14/2022, 6:25 PM
It fails with that constraint but the
pants.toml
constraint
Copy code
[python]
interpreter_constraints = ["CPython==3.8.*"]
succeeds when I remove the explicit constraint on the BUILD target. The tagged version
0.56.0
of
numba
shows min_python_version = "3.7" max_python_version = "3.11" . So it seems that I cannot use >3.8 but I'm not sure why that is only an issue when running via pex rather than targeting source.
h

hundreds-father-404

12/14/2022, 6:30 PM
ah BUILD file constraints override
[python].interpreter_constraints
, which only sets the defualt
e

enough-analyst-54434

12/14/2022, 7:03 PM
I can't tell, did you all figure out that the `<4`was the killer here? That's a bad default. It includes not just 3.11 but 3.12 alphas out now. We should probably force you to pick ICs and not default for you.
👍 1
😮 1
Whatever the default ICs are get written into PEX files, so when the PEX file boots, if is finds any interpreter in that default range, it'll try to use it and boom.
Actually, I fixed the latter a while back, the PEX runtime will figure out 3.11 is no good and use 3.10. Your error above is from a resolve.
a

aloof-appointment-30987

12/14/2022, 9:26 PM
@enough-analyst-54434 does that mean the error I'm encountering will be fixed in an upcoming pants release? I was able to narrow this down to interpretter 3.11. I think that is what John said
the PEX runtime will figure out 3.11 is no good and use 3.10
So I now have, in my
pants.toml
Copy code
[python]
interpreter_constraints = ["CPython==3.10.*"]
and that works. Plus, its a reasonable project-wide constraint (I believe) ...oh man, I just found a note on the numba install page
Numba is compatible with Python 3.7–3.10
That explains why the library was not compatible though I'm still learning how to interpret that
WARNING: Discarding <https://files.pythonhosted>
error message. Interestingly, I was not encountering this issue before I added Python 3.10.9 to my pyenv related to another project. Not sure if there is any causation or if I created the issue while configuring other dependencies. Thanks very much for helping me understand and resolve this. I believe I am in good shape.
e

enough-analyst-54434

12/14/2022, 9:28 PM
@aloof-appointment-30987 no, that Pex issue was fixed quite some time ago and Pants has the fix. It was not the issue here at all. The issue here was purely using inappropriate (no) ICs. Now that you're using appropriate ICs, you should be good.
On top of everything else by the way, if you think about what a locker needs to do - imagine you were it - the narrower the IC range, the faster the lock resolve will be when you
./pants update-lockfiles
.
6 Views