Skip to content

Commit d58e67f

Browse files
committed
Use uv to install Python in Docker / devcontainers
Now that uv managed Python installs are more heavily used than the deadsnakes PPA, this is both a better thing to be testing with and makes it easier for us to install the `setuptools` package that our test suite needs. Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
1 parent 7b6defc commit d58e67f

1 file changed

Lines changed: 16 additions & 29 deletions

File tree

Dockerfile

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,32 +41,9 @@ LABEL org.opencontainers.image.source="https://github.com/bloomberg/pystack"
4141

4242
# Install runtime dependencies
4343
RUN apt-get update \
44-
&& apt-get install -y --force-yes --no-install-recommends software-properties-common gpg-agent \
45-
&& add-apt-repository ppa:deadsnakes/ppa \
4644
&& apt-get install -y --force-yes --no-install-recommends \
4745
build-essential \
4846
pkg-config \
49-
python3.7-dev \
50-
python3.7-dbg \
51-
python3.7-distutils \
52-
python3.8-dev \
53-
python3.8-dbg \
54-
python3.8-distutils \
55-
python3.9-dev \
56-
python3.9-dbg \
57-
python3.9-distutils \
58-
python3.10-dev \
59-
python3.10-dbg \
60-
python3.10-distutils \
61-
python3.11-dev \
62-
python3.11-dbg \
63-
python3.11-distutils \
64-
python3.12-dev \
65-
python3.12-dbg \
66-
python3.12-venv \
67-
python3.13-dev \
68-
python3.13-dbg \
69-
python3.13-venv \
7047
make \
7148
cmake \
7249
gdb \
@@ -75,6 +52,7 @@ RUN apt-get update \
7552
lcov \
7653
file \
7754
less \
55+
libcrypt-dev \
7856
libzstd-dev \
7957
liblzma-dev \
8058
libbz2-dev \
@@ -85,21 +63,30 @@ RUN apt-get update \
8563
# Copy the installed files from the elfutils_builder stage
8664
COPY --from=elfutils_builder /usr/local /usr/local
8765

66+
# Install uv
67+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
68+
8869
# Set environment variables
89-
ENV PYTHON=python3.12 \
90-
VIRTUAL_ENV="/venv" \
91-
PATH="/venv/bin:$PATH" \
70+
ENV VIRTUAL_ENV="/venv" \
71+
PATH="/venv/bin:/root/.local/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin" \
9272
PYTHONDONTWRITEBYTECODE=1 \
9373
TZ=UTC \
9474
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
9575

76+
# Install Python interpreters via uv, and install setuptools for each
77+
RUN uv_versions="3.8 3.9 3.10 3.11 3.12 3.13 3.14 3.15" \
78+
&& uv python install --no-config $uv_versions \
79+
&& for ver in $uv_versions; do \
80+
PATH=/root/.local/bin /usr/local/bin/uv pip install --system --break-system-packages --python=python$ver setuptools; \
81+
done
82+
9683
# Copy the required files
9784
COPY pyproject.toml /tmp/
9885

9986
# Install Python packages
100-
RUN $PYTHON -m venv $VIRTUAL_ENV \
101-
&& pip install -U pip wheel setuptools cython pkgconfig \
102-
&& pip install -U --group "/tmp/pyproject.toml:test" --group "/tmp/pyproject.toml:extra"
87+
RUN uv venv $VIRTUAL_ENV \
88+
&& uv pip install pip wheel setuptools cython pkgconfig \
89+
&& uv pip install --group "/tmp/pyproject.toml:test" --group "/tmp/pyproject.toml:extra"
10390

10491
# Set the working directory
10592
WORKDIR /src

0 commit comments

Comments
 (0)