diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index a8b69ac..d77b3f1 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -5,18 +5,23 @@ 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: [macos-11] #### TEMP # [ubuntu-latest, macos-11] + 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: Set up SSH + # uses: mxschmitt/action-tmate@v3 - name: Build the wheels # The following line here and elsewhere is needed for our Conda environment to # be activated. See: diff --git a/ci/build.sh b/ci/build.sh index 32b4e32..8ababcf 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -17,14 +17,20 @@ 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 +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 @@ -61,11 +67,14 @@ 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 + +export PKG_CONFIG_LIBDIR=$CONDA_PREFIX/lib/pkgconfig + # 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 +cmake -S . -B build $CMAKE_OPTIONS # Build Poppler pushd build @@ -73,23 +82,38 @@ make -j$(nproc) make install popd +export -n LDFLAGS PKG_CONFIG_LIBDIR + 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 + +export PKG_CONFIG_LIBDIR=$POPPLER_LIB_DIR/pkgconfig:$CONDA_PREFIX/lib/pkgconfig + +sip-wheel --verbose $SIP_EXTRA_ARGS --build-dir=build + +export -n PKG_CONFIG_LIBDIR # 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/ # Repack the wheel popd