Skip to content

Commit b3846e5

Browse files
committed
CI: Also build macOS wheels
1 parent a04f39a commit b3846e5

File tree

2 files changed

+51
-18
lines changed

2 files changed

+51
-18
lines changed

.github/workflows/build_wheels.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@ on: [push, pull_request]
55
# versions and macOS / Windows.
66

77
jobs:
8-
build_wheels_linux:
9-
name: Build Linux wheels
10-
# The Docker container the job is run in.
11-
container: quay.io/pypa/manylinux2014_x86_64
8+
build_wheels:
9+
strategy:
10+
matrix:
11+
os: [ubuntu-latest, macos-latest]
12+
name: Build wheels
1213
# The host system that runs Docker.
13-
runs-on: ubuntu-latest
14+
runs-on: ${{ matrix.os }}
15+
# The Docker container the job is run in.
16+
container: ${{ matrix.os == 'ubuntu-latest' && 'quay.io/pypa/manylinux2014_x86_64' || null }}
1417
steps:
1518
- uses: actions/checkout@v3
1619
- uses: conda-incubator/setup-miniconda@v2
1720
with:
1821
miniconda-version: latest
19-
environment-file: ci/environment/conda-linux-64.lock
22+
environment-file: ${{ matrix.os == 'ubuntu-latest' && 'ci/environment/conda-linux-64.lock' || 'ci/environment/conda-osx-64.lock' }}
2023
- name: Build the wheels
2124
# The following line here and elsewhere is needed for our Conda environment to
2225
# be activated. See:

ci/build.sh

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,21 @@ RPATH_OPTION="-Wl,-rpath,'\$ORIGIN',--disable-new-dtags"
1717
# Shell quoting madness to survive through qmake and make ...
1818
RPATH_OPTION_2="-Wl,-rpath,'\\'\\\$\\\$ORIGIN\\'',--disable-new-dtags"
1919

20+
if [ "$OSTYPE" == "linux-gnu" ]; then
21+
export LIBRARY_PATH=$CONDA_BUILD_SYSROOT/lib:$CONDA_PREFIX/lib
22+
else # macOS
23+
export LIBRARY_PATH=$CONDA_PREFIX/lib
24+
export MACOSX_DEPLOYMENT_TARGET=11.0
25+
fi
26+
2027
# Download and extract the Poppler source code
2128

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

2936

3037
pushd $POPPLER
@@ -61,10 +68,12 @@ CMAKE_OPTIONS+=" -DBUILD_QT5_TESTS=OFF"
6168
# Install locally
6269
CMAKE_OPTIONS+=" -DCMAKE_INSTALL_PREFIX==../../../installed-poppler"
6370

71+
if [ "$OSTYPE" == "linux-gnu" ]; then
72+
export LDFLAGS=$RPATH_OPTION
73+
fi
74+
6475
# Generate Poppler Makefile
65-
LDFLAGS=$RPATH_OPTION \
6676
PKG_CONFIG_LIBDIR=$CONDA_PREFIX/lib/pkgconfig \
67-
LIBRARY_PATH=$CONDA_BUILD_SYSROOT/lib:$CONDA_PREFIX/lib \
6877
cmake -S . -B build $CMAKE_OPTIONS
6978

7079
# Build Poppler
@@ -73,23 +82,44 @@ make -j$(nproc)
7382
make install
7483
popd
7584

85+
export -n LDFLAGS
86+
7687
popd
7788

7889
# Now build python-poppler-qt5. Add a RUNPATH just like for poppler.
79-
PKG_CONFIG_LIBDIR=installed-poppler/lib64/pkgconfig:$CONDA_PREFIX/lib/pkgconfig \
80-
LIBRARY_PATH=$CONDA_BUILD_SYSROOT/lib:$CONDA_PREFIX/lib \
81-
sip-wheel --verbose --link-args=$RPATH_OPTION_2 --build-dir=build
90+
if [ "$OSTYPE" == "linux-gnu" ]; then
91+
SIP_EXTRA_ARGS="--link-args=$RPATH_OPTION_2"
92+
POPPLER_LIB_DIR=installed-poppler/lib64
93+
else
94+
SIP_EXTRA_ARGS=
95+
POPPLER_LIB_DIR=installed-poppler/lib
96+
fi
97+
98+
PKG_CONFIG_LIBDIR=$POPPLER_LIB_DIR/pkgconfig:$CONDA_PREFIX/lib/pkgconfig \
99+
sip-wheel --verbose $SIP_EXTRA_ARGS --build-dir=build
82100

83101
# Unpack wheel to tinker with it
84102
WHEEL=(python_poppler_qt5*.whl)
85-
wheel unpack $WHEEL
103+
wheel unpack "$WHEEL"
86104
pushd python_poppler_qt5-$PYTHON_POPPLER_QT5_VERSION
87105

88106
# Vendor libopenjp2 and libjpeg
89-
cp ../installed-poppler/lib64/*.so* \
90-
$CONDA_PREFIX/lib/libopenjp2.so* \
91-
$CONDA_PREFIX/lib/libjpeg.so* \
92-
PyQt5/Qt5/lib/
107+
if [ "$OSTYPE" == "linux-gnu" ]; then
108+
LIB_FILES="../$POPPLER_LIB_DIR/*.so* $CONDA_PREFIX/lib/libopenjp2.so* $CONDA_PREFIX/lib/libjpeg.so*"
109+
else
110+
LIB_FILES="../$POPPLER_LIB_DIR/*.dylib* $CONDA_PREFIX/lib/libopenjp2.dylib* $CONDA_PREFIX/lib/libjpeg.dylib*"
111+
fi
112+
113+
cp $LIB_FILES PyQt5/Qt5/lib/
114+
115+
pushd PyQt5/Qt5/lib
116+
if [ "$OSTYPE" != "linux-gnu" ]; then
117+
for file in _popplerqt5*.so poppler*.dylib; do
118+
install_name_tool -delete_rpath "$CONDA_PREFIX/lib" "$file"
119+
install_name_tool -add_rpath "@loader_path" "$file"
120+
done
121+
fi
122+
popd
93123

94124
# Repack the wheel
95125
popd

0 commit comments

Comments
 (0)