Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ RUN mkdir -p ${HOME} && \
useradd --uid ${UID} --gid ${GID} --home ${HOME} vscode && \
chown -R ${UID}:${GID} /home/vscode

# Fix pyenv installation
RUN echo 'eval "$(pyenv init -)"' >>${HOME}/.bashrc && \
chown -R vscode:vscode "${PYENV_ROOT}" && \
chown -R vscode:vscode "${PIPX_HOME}"
# Allow uv to download Python versions manually
ENV UV_PYTHON_DOWNLOADS=manual

# Set user
USER ${UID}:${GID}
74 changes: 25 additions & 49 deletions .github/containers/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM ubuntu:20.04
FROM ubuntu:24.04
ARG TARGETPLATFORM

# Install OS packages
Expand All @@ -23,33 +23,15 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
bash \
build-essential \
curl \
default-libmysqlclient-dev \
expat \
fish \
fontconfig \
freetds-common \
freetds-dev \
gcc \
git \
libbz2-dev \
libcurl4-openssl-dev \
libffi-dev \
libgmp-dev \
libkrb5-dev \
liblzma-dev \
libmpfr-dev \
libncurses-dev \
libpq-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
locales \
make \
odbc-postgresql \
openssl \
pkg-config \
python3-dev \
python3-pip \
rustc \
sudo \
tzdata \
Expand All @@ -58,8 +40,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
vim \
wget \
zip \
zlib1g \
zlib1g-dev \
zsh && \
rm -rf /var/lib/apt/lists/*

Expand Down Expand Up @@ -103,36 +83,32 @@ RUN ln -fs "/usr/share/zoneinfo/${TZ}" /etc/localtime && \
ENV HOME=/root
WORKDIR "${HOME}"

# Install pyenv
ENV PYENV_ROOT="/usr/local/pyenv"
RUN curl https://pyenv.run/ | /bin/bash
ENV PATH="${PYENV_ROOT}/bin:${PYENV_ROOT}/shims:${PATH}"
RUN echo 'eval "$(pyenv init -)"' >>${HOME}/.bashrc && \
pyenv update
# Install and configure uv
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
ENV PATH="${HOME}/.local/bin:${PATH}"
ENV UV_PYTHON_PREFERENCE="only-managed"

# Install Python
ARG PYTHON_VERSIONS="3.13 3.12 3.11 3.10 3.9 3.8 pypy3.10-7.3.17"
COPY --chown=0:0 --chmod=755 ./install-python.sh /tmp/install-python.sh
RUN /tmp/install-python.sh && \
rm /tmp/install-python.sh
ARG PYTHON_VERSIONS="3.13 3.12 3.11 3.10 3.9 3.8 pypy3.10"
RUN bash -c "uv python install ${PYTHON_VERSIONS}" && \
uv python pin --global 3.13

# Install dependencies for main python installation
COPY ./requirements.txt /tmp/requirements.txt
RUN pyenv exec pip install --upgrade -r /tmp/requirements.txt && \
rm /tmp/requirements.txt
# Add shims for python and pip
COPY --chmod=775 <<EOF "${HOME}/.local/bin/python"
#!/bin/bash
exec uv run --no-project python \$@
EOF

# Install tools with pipx in isolated environments
COPY ./requirements-tools.txt /tmp/requirements-tools.txt
ENV PIPX_HOME="/opt/pipx"
ENV PIPX_BIN_DIR="${PIPX_HOME}/bin"
ENV PATH="${PIPX_BIN_DIR}:${PATH}"
RUN mkdir -p "${PIPX_BIN_DIR}" && \
while IFS="" read -r line || [ -n "$line" ]; do \
pyenv exec pipx install --global "${line}"; \
done </tmp/requirements-tools.txt && \
rm /tmp/requirements-tools.txt
COPY --chmod=775 <<EOF "${HOME}/.local/bin/pip"
#!/bin/bash
exec uv pip \$@
EOF

# Inject compatibile dependencies for tox
COPY ./requirements-tox.txt /tmp/requirements-tox.txt
RUN pipx inject --force tox -r /tmp/requirements-tox.txt && \
rm /tmp/requirements-tox.txt
# Prevent any runtime downloads
ENV UV_PYTHON_DOWNLOADS=never

# Install tools with uv in isolated environments
RUN uv tool install tox==4.23.2 --with tox-uv && \
uv tool install ruff && \
uv tool install pre-commit --with pre-commit-uv && \
uv tool install asv --with virtualenv
10 changes: 3 additions & 7 deletions .github/containers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

# Override constants
PLATFORM_OVERRIDE:=
PYTHON_VERSIONS_OVERRIDE:=

# Computed variables
IMAGE_NAME:=ghcr.io/newrelic/newrelic-python-agent-ci
Expand All @@ -23,8 +22,6 @@ REPO_ROOT:=$(realpath ${MAKEFILE_DIR}../../)
UNAME_P:=$(shell uname -p)
PLATFORM_AUTOMATIC:=$(if $(findstring arm,${UNAME_P}),linux/arm64,linux/amd64)
PLATFORM:=$(if ${PLATFORM_OVERRIDE},${PLATFORM_OVERRIDE},${PLATFORM_AUTOMATIC})
PYTHON_VERSIONS_AUTOMATIC:=3.10
PYTHON_VERSIONS:=$(if ${PYTHON_VERSIONS_OVERRIDE},${PYTHON_VERSIONS_OVERRIDE},${PYTHON_VERSIONS_AUTOMATIC})

.PHONY: default
default: test
Expand All @@ -33,8 +30,7 @@ default: test
build:
@docker build ${MAKEFILE_DIR} \
--platform=${PLATFORM} \
-t ${IMAGE_NAME}:local \
--build-arg='PYTHON_VERSIONS=${PYTHON_VERSIONS}'
-t ${IMAGE_NAME}:local

# Run the local tag as a container.
.PHONY: run
Expand Down Expand Up @@ -62,12 +58,12 @@ run.%:
-e GITHUB_ACTIONS="true" \
${IMAGE_NAME}:$* /bin/bash

# Ensure python versions are usable. Cannot be automatically used with PYTHON_VERSIONS_OVERRIDE.
# Ensures python versions are usable.
.PHONY: test
test: build
@docker run --rm \
--platform=${PLATFORM} \
ghcr.io/newrelic/python-agent-ci:local \
${IMAGE_NAME}:local \
/bin/bash -c '\
python3.10 --version && \
touch tox.ini && tox --version && \
Expand Down
50 changes: 0 additions & 50 deletions .github/containers/install-python.sh

This file was deleted.

2 changes: 0 additions & 2 deletions .github/containers/requirements-tools.txt

This file was deleted.

2 changes: 0 additions & 2 deletions .github/containers/requirements-tox.txt

This file was deleted.

5 changes: 0 additions & 5 deletions .github/containers/requirements.txt

This file was deleted.

42 changes: 0 additions & 42 deletions .github/scripts/retry.sh

This file was deleted.

4 changes: 1 addition & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

[tox]
setupdir = {toxinidir}
uv_python_preference = only-managed
; Fail tests when interpreters are missing.
skip_missing_interpreters = false
envlist =
Expand Down Expand Up @@ -472,9 +473,6 @@ commands =
allowlist_externals =
{toxinidir}/.github/scripts/*

install_command=
{toxinidir}/.github/scripts/retry.sh 3 pip install {opts} {packages}

extras =
agent_streaming: infinite-tracing

Expand Down
Loading