Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanas committed Oct 26, 2023
1 parent a04f39a commit bcdb4ca
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 20 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
52 changes: 38 additions & 14 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -61,35 +67,53 @@ 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
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
Expand Down

0 comments on commit bcdb4ca

Please sign in to comment.