Skip to content

Instantly share code, notes, and snippets.

@bpcreech
Created March 5, 2024 17:12
Show Gist options
  • Save bpcreech/0d6f08a279469a9aebcac02c8a4c73df to your computer and use it in GitHub Desktop.
Save bpcreech/0d6f08a279469a9aebcac02c8a4c73df to your computer and use it in GitHub Desktop.
python-build-standalone pip problems on Alpine
$ sudo docker run -v /home/ben/workspace:/workspace -it alpine:3.19
/ # apk add wget python3
...
/ # wget https://github.com/indygreg/python-build-standalone/releases/download/20240224/cpython-3.12.2+20240224-x86_64-unknown-linux-musl-install_only
.tar.gz
...
/ # tar xfz cpython-3.12.2+20240224-x86_64-unknown-linux-musl-install_only.tar.gz
/ # python/bin/python -m venv /venv
Error: Command '['/venv/bin/python', '-m', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
/ # /venv/bin/python -m ensurepip --upgrade --default-pip
ERROR: Exception:
Traceback (most recent call last):
File "/tmp/tmpfxdt_qrf/pip-24.0-py3-none-any.whl/pip/_internal/cli/base_command.py", line 180, in exc_logging_wrapper
status = run_func(*args)
^^^^^^^^^^^^^^^
File "/tmp/tmpfxdt_qrf/pip-24.0-py3-none-any.whl/pip/_internal/cli/req_command.py", line 245, in wrapper
return func(self, options, args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/tmpfxdt_qrf/pip-24.0-py3-none-any.whl/pip/_internal/commands/install.py", line 324, in run
session = self.get_default_session(options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/tmpfxdt_qrf/pip-24.0-py3-none-any.whl/pip/_internal/cli/req_command.py", line 95, in get_default_session
self._session = self.enter_context(self._build_session(options))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/tmpfxdt_qrf/pip-24.0-py3-none-any.whl/pip/_internal/cli/req_command.py", line 122, in _build_session
session = PipSession(
^^^^^^^^^^^
File "/tmp/tmpfxdt_qrf/pip-24.0-py3-none-any.whl/pip/_internal/network/session.py", line 342, in __init__
self.headers["User-Agent"] = user_agent()
^^^^^^^^^^^^
File "/tmp/tmpfxdt_qrf/pip-24.0-py3-none-any.whl/pip/_internal/network/session.py", line 150, in user_agent
zip(["lib", "version"], libc_ver()),
^^^^^^^^^^
File "/tmp/tmpfxdt_qrf/pip-24.0-py3-none-any.whl/pip/_internal/utils/glibc.py", line 84, in libc_ver
glibc_version = glibc_version_string()
^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/tmpfxdt_qrf/pip-24.0-py3-none-any.whl/pip/_internal/utils/glibc.py", line 8, in glibc_version_string
return glibc_version_string_confstr() or glibc_version_string_ctypes()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/tmpfxdt_qrf/pip-24.0-py3-none-any.whl/pip/_internal/utils/glibc.py", line 43, in glibc_version_string_ctypes
process_namespace = ctypes.CDLL(None)
^^^^^^^^^^^^^^^^^
File "//python/lib/python3.12/ctypes/__init__.py", line 379, in __init__
self._handle = _dlopen(self._name, mode)
^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: Dynamic loading not supported
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "//python/lib/python3.12/ensurepip/__main__.py", line 5, in <module>
sys.exit(ensurepip._main())
^^^^^^^^^^^^^^^^^
File "//python/lib/python3.12/ensurepip/__init__.py", line 284, in _main
return _bootstrap(
^^^^^^^^^^^
File "//python/lib/python3.12/ensurepip/__init__.py", line 200, in _bootstrap
return _run_pip([*args, *_PACKAGE_NAMES], additional_paths)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "//python/lib/python3.12/ensurepip/__init__.py", line 101, in _run_pip
return subprocess.run(cmd, check=True).returncode
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "//python/lib/python3.12/subprocess.py", line 571, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/venv/bin/python', '-W', 'ignore::DeprecationWarning', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/tmp/tmpfxdt_qrf/pip-24.0-py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/tmp/tmpfxdt_qrf\', \'--upgrade\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 2.
/ # ls -al python/lib/python3.12/ensurepip/_bundled/pip-24.0-py3-none-any.whl
-rw-rw-r-- 1 root root 2110226 Jan 1 00:00 python/lib/python3.12/ensurepip/_bundled/pip-24.0-py3-none-any.whl
/ # mkdir bundled_pip
/ # cd bundled_pip
/ # unzip ../python/lib/python3.12/ensurepip/_bundled/pip-24.0-py3-none-any.whl
...
/ # less pip/_internal/utils/glibc.py
(observe, does not have cpython-unix/patch-pip-static-binary.patch)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment