Anyone have any ideas what is causing this weird p...
# general
s
Anyone have any ideas what is causing this weird pex error??
Copy code
Traceback (most recent call last):
  File "/home/nssvc/talos/.pants.d/run/py/CPython-3.6.8/c0d75e5877b552953184e98f54fba0fb2872d067/.bootstrap/pex/pex.py", line 486, in execute
    self.activate()
  File "/home/nssvc/talos/.pants.d/run/py/CPython-3.6.8/c0d75e5877b552953184e98f54fba0fb2872d067/.bootstrap/pex/pex.py", line 133, in activate
    self._working_set = self._activate()
  File "/home/nssvc/talos/.pants.d/run/py/CPython-3.6.8/c0d75e5877b552953184e98f54fba0fb2872d067/.bootstrap/pex/pex.py", line 118, in _activate
    for dist in env.activate():
  File "/home/nssvc/talos/.pants.d/run/py/CPython-3.6.8/c0d75e5877b552953184e98f54fba0fb2872d067/.bootstrap/pex/environment.py", line 277, in activate
    self._working_set = self._activate()
  File "/home/nssvc/talos/.pants.d/run/py/CPython-3.6.8/c0d75e5877b552953184e98f54fba0fb2872d067/.bootstrap/pex/environment.py", line 453, in _activate
    resolved = self._resolve(working_set, all_reqs)
  File "/home/nssvc/talos/.pants.d/run/py/CPython-3.6.8/c0d75e5877b552953184e98f54fba0fb2872d067/.bootstrap/pex/environment.py", line 331, in _resolve
    distributions_by_key[distribution.as_requirement().key].append(distribution)
AttributeError: 'NoneType' object has no attribute 'as_requirement
This happens inside of a docker container that runs on centos. Pants 1.30.4. Outside of the container the same process runs without issue. The only difference is that its run locally on a mac vs centos.
e
Well, that error is in Pex 2.1.24 code that is trying to gather up information to display you an error 🤦 : https://github.com/pantsbuild/pex/blob/480516d8602def5f4a407cd6e38baa8ea0dddec1/pex/environment.py#L316-L331 That code is significantly different in Pex 2.1.25+ and I suspect it will not error but give you more info. Without the unresolved requirements error info though, the most obvious thing is the PEX file has macOS specific wheels build into it but not Linux counterparts - i.e.: its not a multiplatform PEX. Or it does have Linux counterparts, but not of the correct interpreter version for the available interpreters in the Linux container; e.g.: The PEX has CPython 3.8 macOS and Linux wheels but the Container just has CPython 3.7.
This may be useful to debug:
Copy code
python3.6 -mvenv pex-tools
source pex-tools/bin/activate
pip install pex==2.1.39
pex-tools <my.pex> repository info -vi4
That will dump verbose info about the distributions the PEX file contains for the version of python pex-tools is installed under. If the PEX has everything needed for that interpreter, you get json output, If not you get something like:
Copy code
$ pex-tools pants.2.3.0.pex repository info -vi4
Traceback (most recent call last):
  File "/home/jsirois/.venv/pex/bin/pex-tools", line 8, in <module>
    sys.exit(main())
  File "/home/jsirois/.venv/pex/lib/python3.9/site-packages/pex/tools/main.py", line 100, in main
    result = func(pex, options)
  File "/home/jsirois/.venv/pex/lib/python3.9/site-packages/pex/tools/commands/repository.py", line 170, in run
    return repository_func(pex, options)
  File "/home/jsirois/.venv/pex/lib/python3.9/site-packages/pex/tools/commands/repository.py", line 188, in _info
    with self._distributions_output(pex, options) as (distributions, output):
  File "/usr/lib/python3.9/contextlib.py", line 117, in __enter__
    return next(self.gen)
  File "/home/jsirois/.venv/pex/lib/python3.9/site-packages/pex/tools/commands/repository.py", line 180, in _distributions_output
    yield tuple(pex.resolve()), out
  File "/home/jsirois/.venv/pex/lib/python3.9/site-packages/pex/pex.py", line 117, in resolve
    for dist in env.resolve():
  File "/home/jsirois/.venv/pex/lib/python3.9/site-packages/pex/environment.py", line 608, in resolve
    self._resolved_dists = self.resolve_dists(all_reqs)
  File "/home/jsirois/.venv/pex/lib/python3.9/site-packages/pex/environment.py", line 629, in resolve_dists
    for qualified_req_or_not_found in self._root_requirements_iter(reqs):
  File "/home/jsirois/.venv/pex/lib/python3.9/site-packages/pex/environment.py", line 573, in _root_requirements_iter
    raise ResolveError(message)
pex.environment.ResolveError: A distribution for pantsbuild-pants could not be resolved in this environment.Found 4 distributions for pantsbuild-pants that do not apply:
1.) The wheel tags for pantsbuild.pants 2.3.0+gite4a00eb2 are cp37-cp37m-linux_x86_64 which do not match the supported tags of DistributionTarget(interpreter=PythonInterpreter('/home/jsirois/.venv/pex/bin/python3', PythonIdentity('/home/jsirois/.venv/pex/bin/python3', 'cp39', 'cp39', 'manylinux_2_33_x86_64', (3, 9, 2)))):
cp39-cp39-manylinux_2_33_x86_64
...
2.) The wheel tags for pantsbuild.pants 2.3.0+gite4a00eb2 are cp37-cp37m-macosx_10_11_x86_64 which do not match the supported tags of DistributionTarget(interpreter=PythonInterpreter('/home/jsirois/.venv/pex/bin/python3', PythonIdentity('/home/jsirois/.venv/pex/bin/python3', 'cp39', 'cp39', 'manylinux_2_33_x86_64', (3, 9, 2)))):
cp39-cp39-manylinux_2_33_x86_64
...
3.) The wheel tags for pantsbuild.pants 2.3.0+gite4a00eb2 are cp38-cp38-linux_x86_64 which do not match the supported tags of DistributionTarget(interpreter=PythonInterpreter('/home/jsirois/.venv/pex/bin/python3', PythonIdentity('/home/jsirois/.venv/pex/bin/python3', 'cp39', 'cp39', 'manylinux_2_33_x86_64', (3, 9, 2)))):
cp39-cp39-manylinux_2_33_x86_64
...
4.) The wheel tags for pantsbuild.pants 2.3.0+gite4a00eb2 are cp38-cp38-macosx_10_11_x86_64 which do not match the supported tags of DistributionTarget(interpreter=PythonInterpreter('/home/jsirois/.venv/pex/bin/python3', PythonIdentity('/home/jsirois/.venv/pex/bin/python3', 'cp39', 'cp39', 'manylinux_2_33_x86_64', (3, 9, 2)))):
cp39-cp39-manylinux_2_33_x86_64
...
This is me running pex-tools installed in a python3.9 venv against the pants.pex we released for 2.3.0. That PEX is multiplatform macOS / Linux, but only for CPython 3.7 & 3.8.
s
Thanks will try this!