Skip to content

Bundle pyenv in the Docker image for on-demand Python versions#225

Merged
Oskar Haarklou Veileborg (BarrensZeppelin) merged 2 commits into
mainfrom
oskar/add-pyenv-to-docker
Jun 3, 2026
Merged

Bundle pyenv in the Docker image for on-demand Python versions#225
Oskar Haarklou Veileborg (BarrensZeppelin) merged 2 commits into
mainfrom
oskar/add-pyenv-to-docker

Conversation

@BarrensZeppelin
Copy link
Copy Markdown
Member

@BarrensZeppelin Oskar Haarklou Veileborg (BarrensZeppelin) commented Jun 3, 2026

Adds pyenv to the socketdev/cli Docker image (just below the uv install), so the image can build and install arbitrary Python versions on demand. Tracked in ENG-5094.

What changed

  • Install pyenv, pinned to v2.7.1 (latest stable; the coana reference used the older v2.6.20), via the pyenv-installer.
  • Add the Alpine build dependencies needed to compile CPython from source (bash + bzip2-dev, libffi-dev, libxslt-dev, linux-headers, ncurses-dev, openssl-dev, readline-dev, sqlite-dev, xz-dev, zlib-dev). bash is required because pyenv and the pyenv-installer are bash scripts.
  • Only the pyenv binary is symlinked onto the PATH; pyenv's shims directory is intentionally omitted, so its shims don't shadow the system Python the CLI runs on.
  • Bump version 2.4.0 -> 2.4.1 (+ uv.lock, CHANGELOG) so this ships in a published image. No CLI code changes.

Verification

Built the image locally (scripts/build_container.sh pypi-build=local stable=false) and replayed every pyenv action the coana CLI invokes (python-versions-manager.ts) inside the container:

  • which pyenv, pyenv global (system), pyenv install --list (241 versions), pyenv versions --bare, pyenv prefix — all succeed.
  • pyenv install --skip-existing 3.11.14 compiles CPython in ~1m18s with no missing-module warnings; the built interpreter runs and imports every stdlib module backed by the added build deps (ssl, ctypes, lzma, bz2, sqlite3, readline, zlib, curses).
  • Confirmed python3 still resolves to the system /usr/local/bin/python3 (3.14.5) and .pyenv/shims is not on PATH.

Public Changelog

The socketdev/cli Docker image now bundles pyenv (v2.7.1) with the build dependencies needed to compile CPython, allowing it to install arbitrary Python versions on demand.

Install pyenv (pinned to v2.7.1) just below uv, along with the Alpine
build dependencies needed to compile CPython from source. This lets the
bundled tooling build/install arbitrary Python versions on demand.

Only the `pyenv` binary is symlinked onto the PATH; pyenv's shims
directory is deliberately left off PATH so its shims don't shadow the
system Python that the CLI runs on. bash is required since pyenv and the
pyenv-installer are bash scripts.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

🚀 Preview package published!

Install with:

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple socketsecurity==2.4.1.dev3

Docker image: socketdev/cli:pr-225

Bump version to 2.4.1 and document the pyenv addition. The CLI is
unchanged; this release exists to publish a Docker image that includes
pyenv for on-demand Python version installation.
@BarrensZeppelin Oskar Haarklou Veileborg (BarrensZeppelin) merged commit dcab444 into main Jun 3, 2026
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants