Skip to content

Commit 47eab4a

Browse files
committed
CI: fix FreeBSD Python version detection
Hard-coded py311-cython3 broke when FreeBSD updated its default Python version. Install python3 first, then compute the correct prefix (e.g. py313-) at runtime so the job doesn't need updating on every Python bump. Matches the fix already applied to CSXCAD. Assisted-by: Claude Sonnet 4.6 Signed-off-by: Thorsten Liebig <thorsten.liebig@gmx.de>
1 parent 0ab8d7f commit 47eab4a

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

.github/workflows/ci.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -899,13 +899,16 @@ jobs:
899899
version: ${{ matrix.machine.version }}
900900
run: |
901901
echo "Install dependencies..."
902-
sudo pkg install -y cmake git boost-libs tinyxml vtk9 hdf5 cgal octave python3 \
903-
py311-pip \
904-
py311-setuptools py311-wheel py311-setuptools-scm \
905-
py311-cython3 py311-numpy py311-h5py py311-matplotlib
906-
# prefix must match FreeBSD's default python
907-
# version. FreeBSD 14.2 uses Python 3.11 so
908-
# use "py311-"
902+
sudo pkg install -y cmake git boost-libs tinyxml vtk9 hdf5 cgal octave python3
903+
# Derive the version prefix from whatever Python FreeBSD ships
904+
# (e.g. "py311" for 3.11, "py313" for 3.13) so the CI doesn't
905+
# break when FreeBSD bumps its default Python version.
906+
PYVER=$(python3 -c "import sys; print('py{}{}'.format(*sys.version_info[:2]))")
907+
sudo pkg install -y ${PYVER}-pip \
908+
${PYVER}-setuptools ${PYVER}-wheel ${PYVER}-setuptools-scm \
909+
${PYVER}-numpy ${PYVER}-h5py ${PYVER}-matplotlib
910+
# cython3 package name varies across FreeBSD quarterly snapshots; use pip
911+
pip install --user --break-system-packages cython
909912
910913
export CXXFLAGS="-Wall -Wextra -Wno-error"
911914
export NCPUS=$(python3 -c 'import os; print(os.cpu_count())')
@@ -961,10 +964,10 @@ jobs:
961964
962965
echo "Create Python venv and install dependencies..."
963966
# remove Python dependencies to see if venv really works
964-
pip uninstall -y CSXCAD openEMS --break-system-packages
965-
sudo pkg remove -y py311-pip \
966-
py311-setuptools py311-wheel py311-setuptools-scm \
967-
py311-cython3 py311-numpy py311-h5py py311-matplotlib
967+
pip uninstall -y CSXCAD openEMS cython --break-system-packages
968+
sudo pkg remove -y ${PYVER}-pip \
969+
${PYVER}-setuptools ${PYVER}-wheel ${PYVER}-setuptools-scm \
970+
${PYVER}-numpy ${PYVER}-h5py ${PYVER}-matplotlib
968971
python3 -m venv ~/venv
969972
. ~/venv/bin/activate
970973
pip install --upgrade pip

0 commit comments

Comments
 (0)