Skip to content

Commit

Permalink
CI: Also build macOS wheels
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanas committed Oct 26, 2023
1 parent a04f39a commit 286742e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 18 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@ on: [push, pull_request]
# versions and macOS / Windows.

jobs:
build_wheels_linux:
name: Build Linux wheels
# The Docker container the job is run in.
container: quay.io/pypa/manylinux2014_x86_64
build_wheels:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
name: Build wheels
# The host system that runs Docker.
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
# The Docker container the job is run in.
container: ${{ matrix.os == 'ubuntu-latest' && 'quay.io/pypa/manylinux2014_x86_64' || null }}
steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: latest
environment-file: ci/environment/conda-linux-64.lock
environment-file: ${{ matrix.os == 'ubuntu-latest' && 'ci/environment/conda-linux-64.lock' || 'ci/environment/conda-osx-64.lock' }}
- name: Build the wheels
# The following line here and elsewhere is needed for our Conda environment to
# be activated. See:
Expand Down
54 changes: 42 additions & 12 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,21 @@ RPATH_OPTION="-Wl,-rpath,'\$ORIGIN',--disable-new-dtags"
# Shell quoting madness to survive through qmake and make ...
RPATH_OPTION_2="-Wl,-rpath,'\\'\\\$\\\$ORIGIN\\'',--disable-new-dtags"

if [ "$OSTYPE" == "linux-gnu" ]; then
export LIBRARY_PATH=$CONDA_BUILD_SYSROOT/lib:$CONDA_PREFIX/lib
else # macOS
export LIBRARY_PATH=$CONDA_PREFIX/lib
export MACOSX_DEPLOYMENT_TARGET=11.0
fi

# Download and extract the Poppler source code

POPPLER=poppler-$POPPLER_VERSION
curl -O https://poppler.freedesktop.org/$POPPLER.tar.xz
tar -xf $POPPLER.tar.xz
tar -xvf $POPPLER.tar.xz
# Patch Poppler to avoid building the tests. Newer Poppler versions have a config
# variable for this.
sed -i 's/add_subdirectory(test)//g' $POPPLER/CMakeLists.txt
sed -iback 's/add_subdirectory(test)//g' $POPPLER/CMakeLists.txt


pushd $POPPLER
Expand Down Expand Up @@ -61,10 +68,12 @@ CMAKE_OPTIONS+=" -DBUILD_QT5_TESTS=OFF"
# Install locally
CMAKE_OPTIONS+=" -DCMAKE_INSTALL_PREFIX==../../../installed-poppler"

if [ "$OSTYPE" == "linux-gnu" ]; then
export LDFLAGS=$RPATH_OPTION
fi

# Generate Poppler Makefile
LDFLAGS=$RPATH_OPTION \
PKG_CONFIG_LIBDIR=$CONDA_PREFIX/lib/pkgconfig \
LIBRARY_PATH=$CONDA_BUILD_SYSROOT/lib:$CONDA_PREFIX/lib \
cmake -S . -B build $CMAKE_OPTIONS

# Build Poppler
Expand All @@ -73,23 +82,44 @@ make -j$(nproc)
make install
popd

export -n LDFLAGS

popd

# Now build python-poppler-qt5. Add a RUNPATH just like for poppler.
PKG_CONFIG_LIBDIR=installed-poppler/lib64/pkgconfig:$CONDA_PREFIX/lib/pkgconfig \
LIBRARY_PATH=$CONDA_BUILD_SYSROOT/lib:$CONDA_PREFIX/lib \
sip-wheel --verbose --link-args=$RPATH_OPTION_2 --build-dir=build
if [ "$OSTYPE" == "linux-gnu" ]; then
SIP_EXTRA_ARGS="--link-args=$RPATH_OPTION_2"
POPPLER_LIB_DIR=installed-poppler/lib64
else
SIP_EXTRA_ARGS=
POPPLER_LIB_DIR=installed-poppler/lib
fi

PKG_CONFIG_LIBDIR=$POPPLER_LIB_DIR/pkgconfig:$CONDA_PREFIX/lib/pkgconfig \
sip-wheel --verbose $SIP_EXTRA_ARGS --build-dir=build

# Unpack wheel to tinker with it
WHEEL=(python_poppler_qt5*.whl)
wheel unpack $WHEEL
wheel unpack "$WHEEL"
pushd python_poppler_qt5-$PYTHON_POPPLER_QT5_VERSION

# Vendor libopenjp2 and libjpeg
cp ../installed-poppler/lib64/*.so* \
$CONDA_PREFIX/lib/libopenjp2.so* \
$CONDA_PREFIX/lib/libjpeg.so* \
PyQt5/Qt5/lib/
if [ "$OSTYPE" == "linux-gnu" ]; then
LIB_FILES="../$POPPLER_LIB_DIR/*.so* $CONDA_PREFIX/lib/libopenjp2.so* $CONDA_PREFIX/lib/libjpeg.so*"
else
LIB_FILES="../$POPPLER_LIB_DIR/*.dylib* $CONDA_PREFIX/lib/libopenjp2.dylib* $CONDA_PREFIX/lib/libjpeg.dylib*"
fi

cp $LIB_FILES PyQt5/Qt5/lib/

pushd PyQt5/Qt5/lib
if [ "$OSTYPE" != "linux-gnu" ]; then
for file in _popplerqt5*.so libpoppler*.dylib; do
install_name_tool -delete_rpath "$CONDA_PREFIX/lib" "$file"
install_name_tool -add_rpath "@loader_path" "$file"
done
fi
popd

# Repack the wheel
popd
Expand Down

0 comments on commit 286742e

Please sign in to comment.