Skip to content

Instantly share code, notes, and snippets.

@stuaxo
Forked from anntzer/cairo-manylinux.sh
Last active December 4, 2019 00:15
Show Gist options
  • Save stuaxo/0c18de880eb3b6bae0cb640864bd03de to your computer and use it in GitHub Desktop.
Save stuaxo/0c18de880eb3b6bae0cb640864bd03de to your computer and use it in GitHub Desktop.
manylinux build script for pycairo
#!/bin/bash
# Written by Antony Lee (@anntzer).
set -e
PYTHON_VERSION=37
PIP="/opt/python/cp$PYTHON_VERSION-cp${PYTHON_VERSION}m/bin/pip"
if ! [[ -e "$PIP" ]]; then
# Not in the manylinux image yet: call self from within docker.
docker run -it \
--mount type=bind,source="$(readlink -f "$(dirname "$0")")",target=/io \
quay.io/pypa/manylinux1_x86_64 \
"/io/$(basename "$0")"
exit
fi
ZLIB_VERSION=1.2.11
LIBPNG_VERSION=1.6.37
FREETYPE_VERSION=2.10.0
EXPAT_VERSION=2.2.9
# FONTCONFIG_VERSION=2.13.1 # Requires one of: libxml2, expat (technically a dependency of Python too); gperf.
PIXMAN_VERSION=0.38.4
CAIRO_VERSION=1.16.0
PYCAIRO_VERSION=1.18.2
cd io
mkdir -p deps wheelhouse
yum install -y xz
download_unpack_cd () {
local url filename
url="$1"
filename="$(basename "$url")"
if ! [[ -e "$filename" ]]; then
curl -LOJ "$url"
fi
if [[ "$filename" =~ '\.tar\.gz' ]]; then
tar -xzf "$filename"
dirname="${filename::${#filename}-7}"
elif [[ "$filename" =~ '\.tar\.bz2' ]]; then
tar -xjf "$filename"
dirname="${filename::${#filename}-8}"
elif [[ "$filename" =~ '\.tar\.xz' ]]; then
xzcat "$filename" | tar -x
dirname="${filename::${#filename}-7}"
else
echo 'Unknown extension' >&2
exit 1
fi
cd "$dirname"
}
install_autoconf () {
local url flags dirname
url="$1"
flags="$2"
(
cd deps
download_unpack_cd "$url"
./configure $flags
make
make install
)
}
build_wheel () {
local url dest
url="$1"
dest="$2"
(
cd deps
download_unpack_cd "$url"
"$PIP" wheel --no-deps --wheel-dir "$dest" .
)
}
install_autoconf "https://zlib.net/zlib-$ZLIB_VERSION.tar.gz"
install_autoconf "https://download.sourceforge.net/libpng/libpng-$LIBPNG_VERSION.tar.gz"
install_autoconf "https://download.savannah.gnu.org/releases/freetype/freetype-$FREETYPE_VERSION.tar.gz"
install_autoconf "https://downloads.sourceforge.net/project/expat/expat/$EXPAT_VERSION/expat-$EXPAT_VERSION.tar.bz2"
# install_autoconf "https://www.freedesktop.org/software/fontconfig/release/fontconfig-$FONTCONFIG_VERSION.tar.gz"
install_autoconf "https://www.cairographics.org/releases/pixman-$PIXMAN_VERSION.tar.gz"
install_autoconf "https://www.cairographics.org/releases/cairo-$CAIRO_VERSION.tar.xz" --disable-gobject
build_wheel "https://github.com/pygobject/pycairo/releases/download/v$PYCAIRO_VERSION/pycairo-$PYCAIRO_VERSION.tar.gz" \
"$(readlink -f wheelhouse)"
auditwheel repair "wheelhouse/pycairo-$PYCAIRO_VERSION-cp$PYTHON_VERSION-cp${PYTHON_VERSION}m-linux_x86_64.whl"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment