Skip to content

Commit 1d34e9e

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 4ad465e commit 1d34e9e

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
@@ -917,13 +917,16 @@ jobs:
917917
version: ${{ matrix.machine.version }}
918918
run: |
919919
echo "Install dependencies..."
920-
sudo pkg install -y cmake git boost-libs tinyxml vtk9 hdf5 cgal octave python3 \
921-
py311-pip \
922-
py311-setuptools py311-wheel py311-setuptools-scm \
923-
py311-cython3 py311-numpy py311-h5py py311-matplotlib
924-
# prefix must match FreeBSD's default python
925-
# version. FreeBSD 14.2 uses Python 3.11 so
926-
# use "py311-"
920+
sudo pkg install -y cmake git boost-libs tinyxml vtk9 hdf5 cgal octave python3
921+
# Derive the version prefix from whatever Python FreeBSD ships
922+
# (e.g. "py311" for 3.11, "py313" for 3.13) so the CI doesn't
923+
# break when FreeBSD bumps its default Python version.
924+
PYVER=$(python3 -c "import sys; print('py{}{}'.format(*sys.version_info[:2]))")
925+
sudo pkg install -y ${PYVER}-pip \
926+
${PYVER}-setuptools ${PYVER}-wheel ${PYVER}-setuptools-scm \
927+
${PYVER}-numpy ${PYVER}-h5py ${PYVER}-matplotlib
928+
# cython3 package name varies across FreeBSD quarterly snapshots; use pip
929+
pip install --user --break-system-packages cython
927930
928931
export CXXFLAGS="-Wall -Wextra -Wno-error"
929932
export NCPUS=$(python3 -c 'import os; print(os.cpu_count())')
@@ -982,10 +985,10 @@ jobs:
982985
983986
echo "Create Python venv and install dependencies..."
984987
# remove Python dependencies to see if venv really works
985-
pip uninstall -y CSXCAD openEMS --break-system-packages
986-
sudo pkg remove -y py311-pip \
987-
py311-setuptools py311-wheel py311-setuptools-scm \
988-
py311-cython3 py311-numpy py311-h5py py311-matplotlib
988+
pip uninstall -y CSXCAD openEMS cython --break-system-packages
989+
sudo pkg remove -y ${PYVER}-pip \
990+
${PYVER}-setuptools ${PYVER}-wheel ${PYVER}-setuptools-scm \
991+
${PYVER}-numpy ${PYVER}-h5py ${PYVER}-matplotlib
989992
python3 -m venv ~/venv
990993
. ~/venv/bin/activate
991994
pip install --upgrade pip

0 commit comments

Comments
 (0)