Skip to content

Commit

Permalink
Merge pull request #3 from Someware-fr/gdal-3
Browse files Browse the repository at this point in the history
Gdal 3 support
  • Loading branch information
jthiard authored Dec 23, 2020
2 parents cbdad3e + 068b204 commit 450641a
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 34 deletions.
67 changes: 37 additions & 30 deletions Dockerfile.wheels
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ RUN sed -i 's/enabled=1/enabled=0/' /etc/yum/pluginconf.d/fastestmirror.conf \
&& sed -i 's/mirrorlist/#mirrorlist/' /etc/yum.repos.d/CentOS-Base.repo \
&& sed -i 's|#baseurl=http://mirror.centos.org/centos/$releasever|baseurl=http://vault.centos.org/5.11|' /etc/yum.repos.d/CentOS-Base.repo

RUN yum update -y && yum install -y curl-devel json-c-devel zlib-devel libtiff-devel
RUN yum update -y && yum install -y curl-devel json-c-devel zlib-devel libtiff-devel krb5-devel pam-devel cyrus-sasl-devel


# Install openssl
RUN mkdir -p /src \
Expand All @@ -23,7 +24,7 @@ RUN mkdir -p /src \
&& tar zxf openssl-1.0.2o.tar.gz \
&& cd /src/openssl-1.0.2o \
&& ./config no-shared no-ssl2 no-async -fPIC -O2 \
&& make -j 4 \
&& make -j 8 \
&& make install \
&& rm -rf /src

Expand All @@ -34,18 +35,18 @@ RUN mkdir -p /src \
&& tar jxf curl-7.59.0.tar.bz2 \
&& cd /src/curl-7.59.0 \
&& LIBS=-ldl CFLAGS="-O2 -Wl,-S" ./configure --with-ssl=/usr/local/ssl \
&& make -j 4 \
&& make -j 8 \
&& make install \
&& rm -rf /src

# Install geos
RUN mkdir -p /src \
&& cd /src \
&& curl -f -L -O http://download.osgeo.org/geos/geos-3.6.3.tar.bz2 \
&& tar jxf geos-3.6.3.tar.bz2 \
&& cd /src/geos-3.6.3 \
&& curl -f -L -O http://download.osgeo.org/geos/geos-3.8.1.tar.bz2 \
&& tar jxf geos-3.8.1.tar.bz2 \
&& cd /src/geos-3.8.1 \
&& CFLAGS="-O2 -Wl,-S" CXXFLAGS="-O2 -Wl,-S" ./configure \
&& make -j 4 \
&& make -j 8 \
&& make install \
&& rm -rf /src

Expand All @@ -56,18 +57,18 @@ RUN mkdir -p /src \
&& tar xzf jasper-1.900.1.uuid.tar.gz \
&& cd /src/jasper-1.900.1.uuid \
&& ./configure --disable-debug --enable-shared \
&& make -j 4 \
&& make -j 8 \
&& make install \
&& rm -rf /src

# proj4
# proj6
RUN mkdir -p /src \
&& cd /src \
&& curl -f -L -O http://download.osgeo.org/proj/proj-4.9.3.tar.gz \
&& tar xzf proj-4.9.3.tar.gz \
&& cd /src/proj-4.9.3 \
&& curl -f -L -O http://download.osgeo.org/proj/proj-6.3.1.tar.gz \
&& tar xzf proj-6.3.1.tar.gz \
&& cd /src/proj-6.3.1 \
&& ./configure CFLAGS="-O2 -Wl,-S" \
&& make -j 4 \
&& make -j 8 \
&& make install \
&& rm -rf /src

Expand All @@ -77,7 +78,7 @@ RUN cd /usr/local/src \
&& tar xzf cmake-3.11.1.tar.gz \
&& cd cmake-3.11.1 \
&& ./bootstrap --prefix=/usr/local/cmake \
&& make -j 4; make install
&& make -j 8; make install

# openjpeg
RUN mkdir -p /src \
Expand All @@ -88,17 +89,17 @@ RUN mkdir -p /src \
&& mkdir -p build \
&& cd build \
&& /usr/local/cmake/bin/cmake .. -DBUILD_THIRDPARTY:BOOL=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local \
&& make -j 4 install \
&& make -j 8 install \
&& make clean \
&& rm -rf /src

# hdf
RUN cd /usr/local/src \
&& curl -f -L -O https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.2/src/hdf5-1.10.2.tar.gz \
&& tar xzf hdf5-1.10.2.tar.gz \
&& cd hdf5-1.10.2 \
&& curl -f -L -O https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-1.12.0/src/hdf5-1.12.0.tar.gz \
&& tar xzf hdf5-1.12.0.tar.gz \
&& cd hdf5-1.12.0 \
&& ./configure --prefix=/usr/local --enable-shared --enable-build-mode=production CFLAGS="-O2 -Wl,-S" \
&& make -j 4 \
&& make -j 8 \
&& make install

## netcdf
Expand All @@ -107,7 +108,7 @@ RUN cd /usr/local/src \
&& tar xzf netcdf-4.6.1.tar.gz \
&& cd netcdf-4.6.1 \
&& CFLAGS="-I/usr/local/include -O2 -Wl,-S" CXXFLAGS="-I/usr/local/include -O2 -Wl,-S" LDFLAGS="-L/usr/local/lib" ./configure \
&& make -j 4 \
&& make -j 8 \
&& make install

## expat
Expand All @@ -116,7 +117,7 @@ RUN cd /usr/local/src \
&& tar xjf expat-2.2.5.tar.bz2 \
&& cd expat-2.2.5 \
&& CFLAGS="-O2 -Wl,-S" ./configure --prefix=/usr/local \
&& make -j 4 \
&& make -j 8 \
&& make install

## webp
Expand All @@ -125,15 +126,20 @@ RUN cd /usr/local/src \
&& tar xzf libwebp-0.6.1.tar.gz \
&& cd libwebp-0.6.1 \
&& CFLAGS="-O2 -Wl,-S" ./configure --prefix=/usr/local \
&& make -j 4 \
&& make -j 8 \
&& make install

## libpq
ADD build_pg.sh /tmp/build_pg.sh
RUN cd /usr/local/src \
&& bash -x /tmp/build_pg.sh

# gdal
RUN mkdir -p /src \
&& cd /src \
&& curl -f -L -O http://download.osgeo.org/gdal/2.4.0/gdal-2.4.0.tar.gz \
&& tar xzf gdal-2.4.0.tar.gz \
&& cd /src/gdal-2.4.0 \
&& curl -f -L -O https://github.com/OSGeo/gdal/releases/download/v3.1.4/gdal-3.1.4.tar.gz \
&& tar xzf gdal-3.1.4.tar.gz \
&& cd /src/gdal-3.1.4 \
&& CFLAGS="-O2 -Wl,-S" CXXFLAGS="-O2 -Wl,-S" ./configure \
--with-threads \
--disable-debug \
Expand All @@ -154,7 +160,7 @@ RUN mkdir -p /src \
--with-grib \
--with-pam \
--with-geos=/usr/local/bin/geos-config \
--with-static-proj4=/usr/local \
--with-proj=/usr/local \
--with-expat=/usr/local \
--with-libjson-c \
--with-libiconv-prefix=/usr \
Expand All @@ -163,10 +169,11 @@ RUN mkdir -p /src \
--with-netcdf=/usr/local/netcdf \
--with-openjpeg \
--with-jasper=/usr/local \
--with-pg \
--without-python \
--without-hdf4 \
--without-hdf5 \
&& make -j 4 \
--without-hdf4 \
&& make -j 8 \
&& make install

# Bake dev requirements into the Docker image for faster builds
Expand All @@ -181,12 +188,12 @@ RUN for PYBIN in /opt/python/*/bin; do \

# Replace SWIG's setup.py with this modified one, which gets numpy in
# there as a dependency.
ADD setup.py /src/gdal-2.4.0/swig/python/setup.py
ADD setup.py /src/gdal-3.1.4/swig/python/setup.py

# Replace the osgeo module __init__.py with this modified one, which
# sets the GDAL_DATA and PROJ_LIB variables on import to where they've
# been copied to.
ADD gdalinit.py /src/gdal-2.4.0/swig/python/osgeo/__init__.py
ADD gdalinit.py /src/gdal-3.1.4/swig/python/osgeo/__init__.py

WORKDIR /io
CMD ["/io/build-linux-wheels.sh"]
2 changes: 1 addition & 1 deletion build-linux-wheels.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

GDAL_BUILD_PATH=/src/gdal-2.4.0/swig/python
GDAL_BUILD_PATH=/src/gdal-3.1.4/swig/python
ORIGINAL_PATH=$PATH
UNREPAIRED_WHEELS=/tmp/wheels

Expand Down
34 changes: 34 additions & 0 deletions build_pg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# Build libpq for PG 12
# From https://github.com/psycopg/psycopg2-wheels

POSTGRES_TAG="REL_12_5"
POSTGRES_DIR="postgres-${POSTGRES_TAG}"
if [ -d "${POSTGRES_DIR}" ]; then
rm -rf "${POSTGRES_DIR}"
fi

curl -f -L -O https://github.com/postgres/postgres/archive/${POSTGRES_TAG}.tar.gz
tar xzf ${POSTGRES_TAG}.tar.gz

cd "${POSTGRES_DIR}"

# Match the default unix socket dir default with what defined on Ubuntu and
# Red Hat, which seems the most common location
sed -i 's|#define DEFAULT_PGSOCKET_DIR .*'\
'|#define DEFAULT_PGSOCKET_DIR "/var/run/postgresql"|' \
src/include/pg_config_manual.h

./configure --prefix=/usr/local --without-readline \
--with-gssapi --with-openssl --with-pam --without-ldap
make -j8 -C src/interfaces/libpq
make -j8 -C src/bin/pg_config
make -j8 -C src/include

# Install libpq
make -C src/interfaces/libpq install
make -C src/bin/pg_config install
# This will fail after installing postgres_fe.h, which is the bit we need
make -C src/include install || true
cd ..
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Howard Butler [email protected]


gdal_version = '2.4.0'
gdal_version = '3.1.4'

import sys
import shutil
Expand Down Expand Up @@ -50,7 +50,7 @@ def copy_data_tree(datadir, destdir):
except OSError:
pass
shutil.copytree(datadir, destdir)

# ---------------------------------------------------------------------------
# Imports
# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -271,7 +271,7 @@ def finalize_options(self):

packages = ["osgeo",]

readme = str(open('README.txt','rb').read())
readme = ""#str(open('README.txt','rb').read())

name = 'GDAL'
version = gdal_version
Expand Down

0 comments on commit 450641a

Please sign in to comment.