Skip to content

Cannot use pex with statically linked python #2017

@zmanji

Description

@zmanji

due to pypa/pip#6543 it's not possible for pex to resolve dependencies with a statically linked python.

To reproduce in a clean chroot.

$ wget https://github.com/indygreg/python-build-standalone/releases/download/20221220/cpython-3.10.9+20221220-x86_64_v3-unknown-linux-musl-install_only.tar.gz
$ tar xvzf cpython-3.10.9+20221220-x86_64_v3-unknown-linux-musl-install_only.tar.gz 
$ wget https://github.com/pantsbuild/pex/releases/download/v2.1.119/pex
$ ./python/bin/python3 ./pex 'fortune' -o fortune.pex
pid 31 -> /root/.pex/venvs/ffb7a52e5a35c86fd46ad0fdd44b7ac577115b21/58beba50ae31e0c54f07dbf739954fb14f7a9c36/bin/python -sE /root/.pex/venvs/ffb7a52e5a35c86fd46ad0fdd44b7ac577115b21/58beba50ae31e0c54f07dbf739954fb14f7a9c36/pex --disable-pip-version-check --no-python-version-warning --exists-action a --no-input --use-deprecated legacy-resolver --isolated -q --cache-dir /root/.pex/pip_cache download --dest /root/.pex/downloads/resolver_download.oodws27t/python.bin.python3.10 fortune --index-url https://pypi.org/simple --retries 5 --timeout 15 exited with 2 and STDERR:
ERROR: Exception:
Traceback (most recent call last):
  File "/root/.pex/venvs/ffb7a52e5a35c86fd46ad0fdd44b7ac577115b21/58beba50ae31e0c54f07dbf739954fb14f7a9c36/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 223, in _main
    status = self.run(options, args)
  File "/root/.pex/venvs/ffb7a52e5a35c86fd46ad0fdd44b7ac577115b21/58beba50ae31e0c54f07dbf739954fb14f7a9c36/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 180, in wrapper
    return func(self, options, args)
  File "/root/.pex/venvs/ffb7a52e5a35c86fd46ad0fdd44b7ac577115b21/58beba50ae31e0c54f07dbf739954fb14f7a9c36/lib/python3.10/site-packages/pip/_internal/commands/download.py", line 92, in run
    session = self.get_default_session(options)
  File "/root/.pex/venvs/ffb7a52e5a35c86fd46ad0fdd44b7ac577115b21/58beba50ae31e0c54f07dbf739954fb14f7a9c36/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 78, in get_default_session
    self._session = self.enter_context(self._build_session(options))
  File "/root/.pex/venvs/ffb7a52e5a35c86fd46ad0fdd44b7ac577115b21/58beba50ae31e0c54f07dbf739954fb14f7a9c36/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 88, in _build_session
    session = PipSession(
  File "/root/.pex/venvs/ffb7a52e5a35c86fd46ad0fdd44b7ac577115b21/58beba50ae31e0c54f07dbf739954fb14f7a9c36/lib/python3.10/site-packages/pip/_internal/network/session.py", line 248, in __init__
    self.headers["User-Agent"] = user_agent()
  File "/root/.pex/venvs/ffb7a52e5a35c86fd46ad0fdd44b7ac577115b21/58beba50ae31e0c54f07dbf739954fb14f7a9c36/lib/python3.10/site-packages/pip/_internal/network/session.py", line 135, in user_agent
    zip(["lib", "version"], libc_ver()),
  File "/root/.pex/venvs/ffb7a52e5a35c86fd46ad0fdd44b7ac577115b21/58beba50ae31e0c54f07dbf739954fb14f7a9c36/lib/python3.10/site-packages/pip/_internal/utils/glibc.py", line 94, in libc_ver
    glibc_version = glibc_version_string()
  File "/root/.pex/venvs/ffb7a52e5a35c86fd46ad0fdd44b7ac577115b21/58beba50ae31e0c54f07dbf739954fb14f7a9c36/lib/python3.10/site-packages/pip/_internal/utils/glibc.py", line 18, in glibc_version_string
    return glibc_version_string_confstr() or glibc_version_string_ctypes()
  File "/root/.pex/venvs/ffb7a52e5a35c86fd46ad0fdd44b7ac577115b21/58beba50ae31e0c54f07dbf739954fb14f7a9c36/lib/python3.10/site-packages/pip/_internal/utils/glibc.py", line 52, in glibc_version_string_ctypes
    process_namespace = ctypes.CDLL(None)
  File "/python/lib/python3.10/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: Dynamic loading not supported

Changing the pip version does not work because the vendored pip is used to fetch the newer pip. I see two possible solutions:

  • pex3 is released and vendors a newer pip.
  • two pips are vendored much like how two packaging versions are vendored, and when a statically linked python is detected we use the newer pip.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions