From b041664fe5a08140bfe827a72a72029d881051ba Mon Sep 17 00:00:00 2001 From: Jon Griffiths Date: Fri, 5 Jul 2024 09:10:09 +1200 Subject: [PATCH] build: fix swig install under centos/manylinux --- .github/workflows/wheels.yml | 2 +- tools/install_swig.sh | 49 ++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100755 tools/install_swig.sh diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 1470b5361..4d886071d 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -17,7 +17,7 @@ jobs: matrix: os: [ubuntu-22.04, windows-2019, macos-14] env: - CIBW_BEFORE_ALL_LINUX: yum install -y swig || apk add swig + CIBW_BEFORE_ALL_LINUX: ./tools/install_swig.sh CIBW_BEFORE_ALL_MACOS: brew install gnu-sed swig automake libtool CIBW_BEFORE_ALL_WINDOWS: choco install swig --version=3.0.12 --no-progress --allow-downgrade -y CIBW_BEFORE_BUILD_WINDOWS: .\tools\msvc\swig.bat diff --git a/tools/install_swig.sh b/tools/install_swig.sh new file mode 100755 index 000000000..d03441806 --- /dev/null +++ b/tools/install_swig.sh @@ -0,0 +1,49 @@ +#! /usr/bin/env bash +set -e + +if [ $(command -v swig) ]; then + # Already installed + exit 0 +fi + +if [ $(command -v apt) ]; then + # Debian/Ubuntu + apt install swig + exit 0 +fi + +if [ -d /etc/yum.repos.d ]; then + # Redhat/Fedora + if grep -- mirror.centos.org /etc/yum.repos.d/*.repo >/dev/null 2>&1; then + # mirror.centos.org has been nuked. Attempt to update the repo spec + # for older manylinux docker builds + sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo + sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo + sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo + fi + yum install -y swig + exit 0 +fi + +if [ $(command -v brew) ]; then + # MacOS + brew install swig + exit 0 +fi + +if [ $(command -v apk) ]; then + # Alpine + apk add swig + exit 0 +fi + +# Unknown - install from source +SWIG_URL='https://downloads.sourceforge.net/project/swig/swig/swig-3.0.12/swig-3.0.12.tar.gz?use_mirror=autoselect' +curl -sSL ${SWIG_URL} | tar xz +pushd swig-3.0.12 >/dev/null +./configure +make -j4 +make install +popd >/dev/null +rm -rf swig-3.0.12 +exit 0