Skip to content

Commit 5dadf68

Browse files
Add pyenv to Docker image for on-demand Python versions
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.
1 parent a486d4a commit 5dadf68

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,29 @@ ENV GOPATH="/go"
8888
# Install uv
8989
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
9090

91+
# Install pyenv
92+
# pyenv lets us build/install arbitrary Python versions on demand. We install
93+
# the build dependencies needed to compile CPython on Alpine, then install
94+
# pyenv itself. We deliberately only symlink the `pyenv` binary onto the PATH
95+
# and do NOT add pyenv's shims directory, so its shims don't shadow the system
96+
# Python that the CLI runs on.
97+
RUN apk add --no-cache \
98+
bash \
99+
bzip2-dev \
100+
ca-certificates \
101+
libffi-dev \
102+
libxslt-dev \
103+
linux-headers \
104+
ncurses-dev \
105+
openssl-dev \
106+
readline-dev \
107+
sqlite-dev \
108+
xz-dev \
109+
zlib-dev
110+
RUN curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | PYENV_GIT_TAG="v2.7.1" bash && \
111+
ln -s ~/.pyenv/bin/pyenv /bin/pyenv && \
112+
pyenv --version
113+
91114
# Install CLI based on build mode
92115
RUN if [ "$USE_LOCAL_INSTALL" = "true" ]; then \
93116
echo "Using local development install"; \

0 commit comments

Comments
 (0)