Skip to content

Commit

Permalink
Add Python 3.13 to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwartzentruber committed Jan 30, 2025
1 parent 84c6a5a commit b064b0f
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 3 deletions.
5 changes: 5 additions & 0 deletions services/ci-py-313-osx/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: ci-py-313-osx
type: homebrew
base: https://github.com/Homebrew/brew/archive/refs/tags/4.3.5.tar.gz
force_dirty:
- orion-decision
50 changes: 50 additions & 0 deletions services/ci-py-313-osx/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
set -e -x -o pipefail

retry () { i=0; while [[ "$i" -lt 9 ]]; do if "$@"; then return; else sleep 30; fi; i="${i+1}"; done; "$@"; }
retry-curl () { curl -sSL --connect-timeout 25 --fail --retry 5 -w "%{stderr}[downloaded %{url_effective}]\n" "$@"; }

PYTHON_VERSION=3.13.1
STANDALONE_RELEASE=20250115
PYTHON_URL="https://github.com/astral-sh/python-build-standalone/releases/download/${STANDALONE_RELEASE}/cpython-${PYTHON_VERSION}+${STANDALONE_RELEASE}-x86_64-apple-darwin-install_only_stripped.tar.gz"

mkdir -p "$HOMEBREW_PREFIX/opt"
retry-curl "$PYTHON_URL" | tar -C "$HOMEBREW_PREFIX/opt" -xvz
rm -rf "$HOMEBREW_PREFIX"/opt/python/lib/tcl* "$HOMEBREW_PREFIX"/opt/python/lib/tk* "$HOMEBREW_PREFIX"/opt/python/share

# shellcheck disable=SC2016
sed -i '' 's,export PATH=\\",&${HOMEBREW_PREFIX}/opt/python/bin:,' homebrew/Library/Homebrew/cmd/shellenv.sh
PATH="$HOMEBREW_PREFIX/opt/python/bin:$PATH"

# configure pip
mkdir -p pip
cat << EOF > pip/pip.ini
[global]
disable-pip-version-check = true
no-cache-dir = false
[list]
format = columns
[install]
upgrade-strategy = only-if-needed
progress-bar = off
EOF
export PIP_CONFIG_FILE="$PWD/pip/pip.ini"

# install utils to match linux ci images
retry python -m pip install tox
retry python -m pip install poetry
retry python -m pip install pre-commit
retry-curl https://uploader.codecov.io/latest/macos/codecov -o homebrew/bin/codecov
chmod +x homebrew/bin/codecov

mkdir -p .ssh
retry ssh-keyscan github.com > .ssh/known_hosts

rm -rf homebrew/docs
cp -r orion/services/orion-decision orion-decision
cp orion/scripts/relocate_homebrew homebrew/bin/
python -m pip install ./orion-decision
relocate_homebrew
tar -jcvf homebrew.tar.bz2 homebrew pip .ssh
5 changes: 5 additions & 0 deletions services/ci-py-313-win/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: ci-py-313-win
type: msys
base: https://github.com/msys2/msys2-installer/releases/download/2023-10-26/msys2-base-x86_64-20231026.tar.xz
force_dirty:
- orion-decision
78 changes: 78 additions & 0 deletions services/ci-py-313-win/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env bash
set -e -x -o pipefail

retry () { i=0; while [[ "$i" -lt 9 ]]; do if "$@"; then return; else sleep 30; fi; i="$((i+1))"; done; "$@"; }
retry-curl () { curl -sSL --connect-timeout 25 --fail --retry 5 -w "%{stderr}[downloaded %{url_effective}]\n" "$@"; }

# base msys packages
retry pacman --noconfirm -Sy \
mingw-w64-x86_64-curl \
patch \
psmisc \
tar
pacman --noconfirm -Scc
killall -TERM gpg-agent || true
pacman --noconfirm -Rs psmisc

# get nuget
retry-curl "https://aka.ms/nugetclidl" -o msys64/usr/bin/nuget.exe

# get python
VER=3.13.1
retry nuget install python -ExcludeVersion -OutputDirectory . -Version "$VER"
rm -rf msys64/opt/python
mkdir -p msys64/opt
mv python/tools msys64/opt/python
rm -rf python
PATH="$PWD/msys64/opt/python:$PWD/msys64/opt/python/Scripts:$PATH"
which python
python -V

# patch pip to workaround https://github.com/pypa/pip/issues/4368
sed -i "s/^\\( \\)maker = PipScriptMaker(.*/&\r\n\\1maker.executable = '\\/usr\\/bin\\/env python'/" \
msys64/opt/python/Lib/site-packages/pip/_internal/operations/install/wheel.py

# configure pip
mkdir -p pip
cat << EOF > pip/pip.ini
[global]
disable-pip-version-check = true
no-cache-dir = false
[list]
format = columns
[install]
upgrade-strategy = only-if-needed
progress-bar = off
EOF

# force-upgrade pip to include the above patch
# have to use `python -m pip` until PATH is updated externally
# otherwise /usr/bin/env will select the old `pip` in mozbuild
retry python -m pip install --upgrade --force-reinstall pip

# patch new pip to workaround https://github.com/pypa/pip/issues/4368
sed -i "s/^\\( \\)maker = PipScriptMaker(.*/&\r\n\\1maker.executable = '\\/usr\\/bin\\/env python'/" \
msys64/opt/python/Lib/site-packages/pip/_internal/operations/install/wheel.py

# install utils to match linux ci images
retry python -m pip install tox
retry python -m pip install pre-commit
retry-curl https://uploader.codecov.io/latest/windows/codecov.exe -o msys64/usr/bin/codecov.exe

mkdir -p .ssh
retry ssh-keyscan github.com > .ssh/known_hosts

rm -rf \
msys64/mingw64/share/doc/ \
msys64/mingw64/share/info/ \
msys64/mingw64/share/man/ \
msys64/usr/share/doc/ \
msys64/usr/share/info/ \
msys64/usr/share/man/
cp -r orion/services/orion-decision orion-decision
retry python -m pip install ./orion-decision
# Delete symlinks
find msys64 -type l -delete
tar -jcvf msys2.tar.bz2 --hard-dereference msys64 pip .ssh
17 changes: 17 additions & 0 deletions services/ci-py-313/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

FROM python:3.13-slim

LABEL maintainer Jesse Schwartzentruber <[email protected]>

COPY base/linux/etc/pip.conf /etc/pip.conf
COPY recipes/linux /src/recipes
COPY services/ci-py-common/setup-linux.sh /src/recipes/setup.sh
COPY services/orion-decision /src/orion-decision

RUN /src/recipes/setup.sh

USER worker
WORKDIR /home/worker
3 changes: 3 additions & 0 deletions services/ci-py-313/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: ci-py-313
force_dirty:
- orion-decision
4 changes: 4 additions & 0 deletions services/orion-decision/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ tests:
type: tox
image: ci-py-312
toxenv: py312
- name: python 3.13 unittests
type: tox
image: ci-py-313
toxenv: py313
- name: lint
type: tox
image: ci-py-39
Expand Down
9 changes: 6 additions & 3 deletions services/orion-decision/src/orion_decision/ci_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
VERSIONS = {
("java", "linux"): ["11"],
("node", "linux"): ["18", "20"],
("python", "linux"): ["3.9", "3.10", "3.11", "3.12"],
("python", "windows"): ["3.9", "3.10", "3.11", "3.12"],
("python", "macos"): ["3.9", "3.10", "3.11", "3.12"],
("python", "linux"): ["3.9", "3.10", "3.11", "3.12", "3.13"],
("python", "windows"): ["3.9", "3.10", "3.11", "3.12", "3.13"],
("python", "macos"): ["3.9", "3.10", "3.11", "3.12", "3.13"],
}
IMAGES = {
("java", "linux", "11"): "ci-java-11",
Expand All @@ -37,14 +37,17 @@
("python", "linux", "3.10"): "ci-py-310",
("python", "linux", "3.11"): "ci-py-311",
("python", "linux", "3.12"): "ci-py-312",
("python", "linux", "3.13"): "ci-py-313",
("python", "windows", "3.9"): "ci-py-39-win",
("python", "windows", "3.10"): "ci-py-310-win",
("python", "windows", "3.11"): "ci-py-311-win",
("python", "windows", "3.12"): "ci-py-312-win",
("python", "windows", "3.13"): "ci-py-313-win",
("python", "macos", "3.9"): "ci-py-39-osx",
("python", "macos", "3.10"): "ci-py-310-osx",
("python", "macos", "3.11"): "ci-py-311-osx",
("python", "macos", "3.12"): "ci-py-312-osx",
("python", "macos", "3.13"): "ci-py-313-osx",
}
LOG = getLogger(__name__)

Expand Down

0 comments on commit b064b0f

Please sign in to comment.