Skip to content

Commit f1f407d

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 90ecb15 commit f1f407d

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
@@ -921,13 +921,16 @@ jobs:
921921
version: ${{ matrix.machine.version }}
922922
run: |
923923
echo "Install dependencies..."
924-
sudo pkg install -y cmake git boost-libs tinyxml vtk9 hdf5 cgal octave python3 \
925-
py311-pip \
926-
py311-setuptools py311-wheel py311-setuptools-scm \
927-
py311-cython3 py311-numpy py311-h5py py311-matplotlib
928-
# prefix must match FreeBSD's default python
929-
# version. FreeBSD 14.2 uses Python 3.11 so
930-
# use "py311-"
924+
sudo pkg install -y cmake git boost-libs tinyxml vtk9 hdf5 cgal octave python3
925+
# Derive the version prefix from whatever Python FreeBSD ships
926+
# (e.g. "py311" for 3.11, "py313" for 3.13) so the CI doesn't
927+
# break when FreeBSD bumps its default Python version.
928+
PYVER=$(python3 -c "import sys; print('py{}{}'.format(*sys.version_info[:2]))")
929+
sudo pkg install -y ${PYVER}-pip \
930+
${PYVER}-setuptools ${PYVER}-wheel ${PYVER}-setuptools-scm \
931+
${PYVER}-numpy ${PYVER}-h5py ${PYVER}-matplotlib
932+
# cython3 package name varies across FreeBSD quarterly snapshots; use pip
933+
pip install --user --break-system-packages cython
931934
932935
export CXXFLAGS="-Wall -Wextra -Wno-error"
933936
export NCPUS=$(python3 -c 'import os; print(os.cpu_count())')
@@ -987,10 +990,10 @@ jobs:
987990
988991
echo "Create Python venv and install dependencies..."
989992
# remove Python dependencies to see if venv really works
990-
pip uninstall -y CSXCAD openEMS --break-system-packages
991-
sudo pkg remove -y py311-pip \
992-
py311-setuptools py311-wheel py311-setuptools-scm \
993-
py311-cython3 py311-numpy py311-h5py py311-matplotlib
993+
pip uninstall -y CSXCAD openEMS cython --break-system-packages
994+
sudo pkg remove -y ${PYVER}-pip \
995+
${PYVER}-setuptools ${PYVER}-wheel ${PYVER}-setuptools-scm \
996+
${PYVER}-numpy ${PYVER}-h5py ${PYVER}-matplotlib
994997
python3 -m venv ~/venv
995998
. ~/venv/bin/activate
996999
pip install --upgrade pip

0 commit comments

Comments
 (0)