Skip to content

Instantly share code, notes, and snippets.

@jcfr
Last active August 2, 2018 15:20
Show Gist options
  • Save jcfr/5bda6e95ef3331f2bb14a4672efcde7a to your computer and use it in GitHub Desktop.
Save jcfr/5bda6e95ef3331f2bb14a4672efcde7a to your computer and use it in GitHub Desktop.
Manylinux docker file to install libtiff and openslide
#FROM quay.io/pypa/manylinux1_x86_64
FROM dockcross/manylinux-x64
# FROM quay.io/pypa/manylinux1_i686
# Includes glibc 2.5
RUN mkdir /build
WORKDIR /build
RUN yum install -y \
# for easier development
man \
vim-enhanced
# Update autotools, perl, m4, pkg-config
RUN curl http://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz -L -o pkg-config.tar.gz && \
mkdir pkg-config && \
tar -zxf pkg-config.tar.gz -C pkg-config --strip-components 1 && \
cd pkg-config && \
./configure --prefix=/usr/local --with-internal-glib --disable-host-tool && \
make && \
make install
# 1.4.17
RUN curl ftp://ftp.gnu.org/gnu/m4/m4-latest.tar.gz -L -o m4.tar.gz && \
mkdir m4 && \
tar -zxf m4.tar.gz -C m4 --strip-components 1 && \
cd m4 && \
./configure --prefix=/usr/local && \
make && \
make install
RUN curl -L http://install.perlbrew.pl | bash && \
. ~/perl5/perlbrew/etc/bashrc && \
echo '. /root/perl5/perlbrew/etc/bashrc' >> /etc/bashrc && \
perlbrew install perl-5.29.0 -j 4 -n && \
perlbrew switch perl-5.29.0
RUN curl http://ftp.gnu.org/gnu/automake/automake-1.16.1.tar.gz -L -o automake.tar.gz && \
mkdir automake && \
tar -zxf automake.tar.gz -C automake --strip-components 1 && \
cd automake && \
./configure --prefix=/usr/local && \
make && \
make install
# 2.69 ?
RUN curl http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz -L -o autoconf.tar.gz && \
mkdir autoconf && \
tar -zxf autoconf.tar.gz -C autoconf --strip-components 1 && \
cd autoconf && \
./configure --prefix=/usr/local && \
make && \
make install
RUN curl http://ftp.gnu.org/gnu/libtool/libtool-2.4.6.tar.gz -L -o libtool.tar.gz && \
mkdir libtool && \
tar -zxf libtool.tar.gz -C libtool --strip-components 1 && \
cd libtool && \
./configure --prefix=/usr/local && \
make && \
make install
# CMake
#RUN curl https://cmake.org/files/v3.11/cmake-3.11.4.tar.gz -L -o cmake.tar.gz && \
# mkdir cmake && \
# tar -zxf cmake.tar.gz -C cmake --strip-components 1 && \
# cd cmake && \
# ./bootstrap && \
# make -j 4 && \
# make install
# OpenJPEG
RUN yum install -y \
# needed for openjpeg
lcms2-devel \
libpng-devel \
zlib-devel
RUN curl https://github.com/uclouvain/openjpeg/archive/v2.3.0.tar.gz -L -o openjpeg.tar.gz && \
mkdir openjpeg && \
tar -zxf openjpeg.tar.gz -C openjpeg --strip-components 1 && \
cd openjpeg && \
cmake . && \
make -j 4 && \
make install && \
ldconfig
# libtiff
# Note: This doesn't support GL or jpeg 8/12
RUN yum install -y \
# needed for libtiff
freeglut-devel \
libjpeg-devel \
mesa-libGL-devel \
mesa-libGLU-devel \
xz-devel
RUN curl https://www.cl.cam.ac.uk/~mgk25/jbigkit/download/jbigkit-2.1.tar.gz -L -o jbigkit.tar.gz && \
mkdir jbigkit && \
tar -zxf jbigkit.tar.gz -C jbigkit --strip-components 1 && \
cd jbigkit/libjbig && \
make && \
cp *.o /usr/local/lib/. && \
cp *.h /usr/local/include/. && \
ldconfig
RUN curl https://download.osgeo.org/libtiff/tiff-4.0.9.tar.gz -L -o tiff.tar.gz && \
mkdir tiff && \
tar -zxf tiff.tar.gz -C tiff --strip-components 1 && \
cd tiff && \
./configure && \
make -j 4 && \
make install && \
ldconfig
# Rebuild openjpeg with our libtiff
RUN cd openjpeg && \
cmake . && \
make -j 4 && \
make install && \
ldconfig
# OpenSlide
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib64/pkgconfig
RUN yum install -y \
# needed for openslide
cairo-devel \
libtool
# Install newer versions of glib2, gdk-pixbuf2, libxml2.
# In our setup.py, we may want to confirm glib2 >= 2.25.9
RUN curl http://ftp.gnome.org/pub/gnome/sources/glib/2.25/glib-2.25.9.tar.gz -L -o glib-2.tar.gz && \
mkdir glib-2 && \
tar -zxf glib-2.tar.gz -C glib-2 --strip-components 1 && \
cd glib-2 && \
export CFLAGS=-fPIC LDFLAGS=-fPIC CPPFLAGS=-fPIC && \
./configure --prefix=/usr/local --enable-static --disable-shared && \
make && \
make install
RUN curl https://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/2.21/gdk-pixbuf-2.21.7.tar.gz -L -o gdk-pixbuf-2.tar.gz && \
mkdir gdk-pixbuf-2 && \
tar -zxf gdk-pixbuf-2.tar.gz -C gdk-pixbuf-2 --strip-components 1 && \
cd gdk-pixbuf-2 && \
export CFLAGS=-fPIC LDFLAGS=-fPIC CPPFLAGS=-fPIC && \
./configure --prefix=/usr/local --enable-static --disable-shared && \
make && \
make install
RUN curl http://xmlsoft.org/sources/libxml2-2.7.8.tar.gz -L -o libxml2.tar.gz && \
mkdir libxml2 && \
tar -zxf libxml2.tar.gz -C libxml2 --strip-components 1 && \
cd libxml2 && \
export CFLAGS=-fPIC LDFLAGS=-fPIC CPPFLAGS=-fPIC && \
./configure --prefix=/usr/local --enable-static --disable-shared && \
make && \
make install
RUN curl https://github.com/openslide/openslide/archive/v3.4.1.tar.gz -L -o openslide.tar.gz && \
mkdir openslide && \
tar -zxf openslide.tar.gz -C openslide --strip-components 1 && \
cd openslide && \
export CFLAGS=-fPIC LDFLAGS=-fPIC CPPFLAGS=-fPIC && \
autoreconf -ifv && \
./configure --enable-static --disable-shared && \
make -j 4 && \
make install && \
ldconfig
# Sample code to insert in the middle of a build cycle for debug
# true
#
#RUN true && \
# cd openslide && \
RUN git clone https://github.com/openslide/openslide-python && \
cd openslide-python && \
python -c 's = open("setup.py").read().replace("_convert.c'\''", "_convert.c'\''], libraries=['\''openslide'\'', '\''Xrender'\''");open("setup.py", "wb").write(s)' && \
/opt/python/cp27-cp27mu/bin/pip wheel . -w wheelhouse/ && \
auditwheel repair wheelhouse/openslide_python-1.1.1-cp27-cp27mu-linux_x86_64.whl -w wheelhouse/ && \
ls -l wheelhouse
@jcfr
Copy link
Author

jcfr commented Aug 2, 2018

List of updates:

  • uses dockcross/manylinux-x64 what already includes the latest version of CMake
  • statically compile all dependencies

Output of autitwheel:

Repairing openslide_python-1.1.1-cp27-cp27mu-linux_x86_64.whl
Previous filename tags: linux_x86_64
New filename tags: manylinux1_x86_64
Previous WHEEL info tags: cp27-cp27mu-linux_x86_64
New WHEEL info tags: cp27-cp27mu-manylinux1_x86_64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment