-
Notifications
You must be signed in to change notification settings - Fork 16
/
config.sh
516 lines (459 loc) · 16.1 KB
/
config.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
# Custom utilities for Rasterio wheels.
#
# Test for OSX with [ -n "$IS_OSX" ].
function fetch_unpack {
# Fetch input archive name from input URL
# Parameters
# url - URL from which to fetch archive
# archive_fname (optional) archive name
#
# Echos unpacked directory and file names.
#
# If `archive_fname` not specified then use basename from `url`
# If `archive_fname` already present at download location, use that instead.
local url=$1
if [ -z "$url" ];then echo "url not defined"; exit 1; fi
local archive_fname=${2:-$(basename $url)}
local arch_sdir="${ARCHIVE_SDIR:-archives}"
# Make the archive directory in case it doesn't exist
mkdir -p $arch_sdir
local out_archive="${arch_sdir}/${archive_fname}"
# If the archive is not already in the archives directory, get it.
if [ ! -f "$out_archive" ]; then
# Source it from multibuild archives if available.
local our_archive="${MULTIBUILD_DIR}/archives/${archive_fname}"
if [ -f "$our_archive" ]; then
ln -s $our_archive $out_archive
else
# Otherwise download it.
curl --insecure -L $url > $out_archive
fi
fi
# Unpack archive, refreshing contents, echoing dir and file
# names.
rm_mkdir arch_tmp
install_rsync
(cd arch_tmp && \
untar ../$out_archive && \
ls -1d * &&
rsync --delete -ah * ..)
}
function build_hdf5 {
if [ -e hdf5-stamp ]; then return; fi
build_zlib
# libaec is a drop-in replacement for szip
build_libaec
local hdf5_url=https://support.hdfgroup.org/ftp/HDF5/releases
local short=$(echo $HDF5_VERSION | awk -F "." '{printf "%d.%d", $1, $2}')
fetch_unpack $hdf5_url/hdf5-$short/hdf5-$HDF5_VERSION/src/hdf5-$HDF5_VERSION.tar.gz
(cd hdf5-$HDF5_VERSION \
&& export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$BUILD_PREFIX/lib \
&& ./configure --with-szlib=$BUILD_PREFIX --prefix=$BUILD_PREFIX \
--enable-cxx --enable-threadsafe --enable-unsupported --with-pthread=yes \
&& make -j4 \
&& make install)
touch hdf5-stamp
}
function build_blosc {
if [ -e blosc-stamp ]; then return; fi
local cmake=cmake
fetch_unpack https://github.com/Blosc/c-blosc/archive/v${BLOSC_VERSION}.tar.gz
(cd c-blosc-${BLOSC_VERSION} \
&& $cmake -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX . \
&& make install)
if [ -n "$IS_MACOS" ]; then
# Fix blosc library id bug
for lib in $(ls ${BUILD_PREFIX}/lib/libblosc*.dylib); do
install_name_tool -id $lib $lib
done
fi
touch blosc-stamp
}
function build_geos {
CFLAGS="$CFLAGS -g -O2"
CXXFLAGS="$CXXFLAGS -g -O2"
if [ -e geos-stamp ]; then return; fi
local cmake=cmake
fetch_unpack http://download.osgeo.org/geos/geos-${GEOS_VERSION}.tar.bz2
(cd geos-${GEOS_VERSION} \
&& mkdir build && cd build \
&& $cmake .. \
-DCMAKE_INSTALL_PREFIX:PATH=$BUILD_PREFIX \
-DCMAKE_OSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_IPO=ON \
-DBUILD_APPS:BOOL=OFF \
-DBUILD_TESTING:BOOL=OFF \
&& $cmake --build . -j4 \
&& $cmake --install .)
touch geos-stamp
}
function build_jsonc {
if [ -e jsonc-stamp ]; then return; fi
local cmake=cmake
fetch_unpack https://s3.amazonaws.com/json-c_releases/releases/json-c-${JSONC_VERSION}.tar.gz
(cd json-c-${JSONC_VERSION} \
&& $cmake -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_OSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET . \
&& make -j4 \
&& make install)
if [ -n "$IS_OSX" ]; then
for lib in $(ls ${BUILD_PREFIX}/lib/libjson-c.5*.dylib); do
install_name_tool -id $lib $lib
done
for lib in $(ls ${BUILD_PREFIX}/lib/libjson-c.dylib); do
install_name_tool -id $lib $lib
done
fi
touch jsonc-stamp
}
function build_proj {
CFLAGS="$CFLAGS -DPROJ_RENAME_SYMBOLS -g -O2"
CXXFLAGS="$CXXFLAGS -DPROJ_RENAME_SYMBOLS -DPROJ_INTERNAL_CPP_NAMESPACE -g -O2"
if [ -e proj-stamp ]; then return; fi
local cmake=cmake
build_sqlite
fetch_unpack http://download.osgeo.org/proj/proj-${PROJ_VERSION}.tar.gz
(cd proj-${PROJ_VERSION} \
&& mkdir build && cd build \
&& $cmake .. \
-DCMAKE_INSTALL_PREFIX:PATH=$BUILD_PREFIX \
-DCMAKE_OSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_IPO=ON \
-DBUILD_APPS:BOOL=OFF \
-DBUILD_TESTING:BOOL=OFF \
&& $cmake --build . -j4 \
&& $cmake --install .)
touch proj-stamp
}
function build_sqlite {
if [ -e sqlite-stamp ]; then return; fi
fetch_unpack https://www.sqlite.org/2020/sqlite-autoconf-${SQLITE_VERSION}.tar.gz
(cd sqlite-autoconf-${SQLITE_VERSION} \
&& ./configure --prefix=$BUILD_PREFIX \
&& make -j4 \
&& make install)
touch sqlite-stamp
}
function build_expat {
if [ -e expat-stamp ]; then return; fi
if [ -n "$IS_OSX" ]; then
:
else
fetch_unpack https://github.com/libexpat/libexpat/releases/download/R_2_2_6/expat-${EXPAT_VERSION}.tar.bz2
(cd expat-${EXPAT_VERSION} \
&& ./configure --prefix=$BUILD_PREFIX \
&& make -j4 \
&& make install)
fi
touch expat-stamp
}
function build_lerc {
if [-e lerc-stamp ]; then return; fi
local cmake=cmake
fetch_unpack https://github.com/Esri/lerc/archive/refs/tags/v${LERC_VERSION}.tar.gz
(cd lerc-${LERC_VERSION} \
&& mkdir cmake_build && cd cmake_build \
&& $cmake .. \
-DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX \
-DCMAKE_OSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_IPO=ON \
&& $cmake --build . -j4 \
&& $cmake --install .)
touch lerc-stamp
}
function build_tiff {
if [ -e tiff-stamp ]; then return; fi
build_lerc
build_jpeg
build_libwebp
build_zlib
build_zstd
build_xz
fetch_unpack https://download.osgeo.org/libtiff/tiff-${TIFF_VERSION}.tar.gz
(cd tiff-${TIFF_VERSION} \
&& mv VERSION VERSION.txt \
&& (patch -u --force < ../patches/libtiff-rename-VERSION.patch || true) \
&& ./configure --prefix=$BUILD_PREFIX --enable-zstd --enable-webp --enable-lerc \
&& make -j4 \
&& make install)
touch tiff-stamp
}
function build_openjpeg {
if [ -e openjpeg-stamp ]; then return; fi
build_zlib
build_tiff
build_lcms2
local cmake=cmake
local archive_prefix="v"
if [ $(lex_ver $OPENJPEG_VERSION) -lt $(lex_ver 2.1.1) ]; then
archive_prefix="version."
fi
local out_dir=$(fetch_unpack https://github.com/uclouvain/openjpeg/archive/${archive_prefix}${OPENJPEG_VERSION}.tar.gz)
(cd $out_dir \
&& $cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_OSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET . \
&& make -j4 \
&& make install)
touch openjpeg-stamp
}
function build_libwebp {
ls -l $BUILD_PREFIX
ls -l $BUILD_PREFIX/share
ls -l $BUILD_PREFIX/share/man
build_libpng
build_giflib
build_simple libwebp $LIBWEBP_VERSION \
https://storage.googleapis.com/downloads.webmproject.org/releases/webp tar.gz \
--enable-libwebpmux --enable-libwebpdemux
}
function build_nghttp2 {
if [ -e nghttp2-stamp ]; then return; fi
fetch_unpack https://github.com/nghttp2/nghttp2/releases/download/v${NGHTTP2_VERSION}/nghttp2-${NGHTTP2_VERSION}.tar.gz
(cd nghttp2-${NGHTTP2_VERSION} \
&& ./configure --enable-lib-only --prefix=$BUILD_PREFIX \
&& make -j4 \
&& make install)
touch nghttp2-stamp
}
function build_openssl {
if [ -e openssl-stamp ]; then return; fi
fetch_unpack ${OPENSSL_DOWNLOAD_URL}/${OPENSSL_ROOT}.tar.gz
check_sha256sum $ARCHIVE_SDIR/${OPENSSL_ROOT}.tar.gz ${OPENSSL_HASH}
(cd ${OPENSSL_ROOT} \
&& ./config no-ssl2 -fPIC --prefix=$BUILD_PREFIX \
&& make -j4 \
&& if [ -n "$IS_OSX" ]; then sudo make install; else make install; fi)
touch openssl-stamp
}
function build_curl {
if [ -e curl-stamp ]; then return; fi
CFLAGS="$CFLAGS -g -O2"
CXXFLAGS="$CXXFLAGS -g -O2"
build_openssl
build_nghttp2
local flags="--prefix=$BUILD_PREFIX --with-nghttp2=$BUILD_PREFIX --with-libz --with-ssl --without-libidn2"
# fetch_unpack https://curl.haxx.se/download/curl-${CURL_VERSION}.tar.gz
(cd curl-${CURL_VERSION} \
&& LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$BUILD_PREFIX/lib:$BUILD_PREFIX/lib64 ./configure $flags \
&& make -j4 \
&& if [ -n "$IS_OSX" ]; then sudo make install; else make install; fi)
touch curl-stamp
}
function build_zstd {
CFLAGS="$CFLAGS -g -O2"
CXXFLAGS="$CXXFLAGS -g -O2"
if [ -e zstd-stamp ]; then return; fi
fetch_unpack https://github.com/facebook/zstd/archive/v${ZSTD_VERSION}.tar.gz
if [ -n "$IS_OSX" ]; then
sed_ere_opt="-E"
else
sed_ere_opt="-r"
fi
(cd zstd-${ZSTD_VERSION} \
&& make -j4 PREFIX=$BUILD_PREFIX ZSTD_LEGACY_SUPPORT=0 \
&& make install PREFIX=$BUILD_PREFIX SED_ERE_OPT=$sed_ere_opt)
touch zstd-stamp
}
function build_pcre2 {
build_simple pcre2 $PCRE_VERSION https://github.com/PCRE2Project/pcre2/releases/download/pcre2-${PCRE_VERSION}
}
function build_gdal {
if [ -e gdal-stamp ]; then return; fi
build_blosc
build_curl
build_lerc
build_jpeg
build_libpng
build_openjpeg
build_jsonc
build_sqlite
build_proj
build_expat
build_geos
build_hdf5
build_netcdf
build_zstd
build_pcre2
CFLAGS="$CFLAGS -DPROJ_RENAME_SYMBOLS -g -O2"
CXXFLAGS="$CXXFLAGS -DPROJ_RENAME_SYMBOLS -DPROJ_INTERNAL_CPP_NAMESPACE -g -O2"
if [ -n "$IS_OSX" ]; then
GEOS_CONFIG="-DGDAL_USE_GEOS=OFF"
PCRE2_LIB="$BUILD_PREFIX/lib/libpcre2-8.dylib"
else
GEOS_CONFIG="-DGDAL_USE_GEOS=ON"
PCRE2_LIB="$BUILD_PREFIX/lib/libpcre2-8.so"
fi
local cmake=cmake
fetch_unpack http://download.osgeo.org/gdal/${GDAL_VERSION}/gdal-${GDAL_VERSION}.tar.gz
(cd gdal-${GDAL_VERSION} \
&& mkdir build \
&& cd build \
&& $cmake .. \
-DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX \
-DCMAKE_INCLUDE_PATH=$BUILD_PREFIX/include \
-DCMAKE_LIBRARY_PATH=$BUILD_PREFIX/lib \
-DCMAKE_PROGRAM_PATH=$BUILD_PREFIX/bin \
-DCMAKE_OSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DGDAL_BUILD_OPTIONAL_DRIVERS=ON \
-DOGR_BUILD_OPTIONAL_DRIVERS=OFF \
${GEOS_CONFIG} \
-DGDAL_USE_CURL=ON \
-DGDAL_USE_TIFF=ON \
-DGDAL_USE_TIFF_INTERNAL=OFF \
-DGDAL_USE_GEOTIFF_INTERNAL=ON \
-DGDAL_ENABLE_DRIVER_GIF=ON \
-DGDAL_ENABLE_DRIVER_GRIB=ON \
-DGDAL_ENABLE_DRIVER_JPEG=ON \
-DGDAL_USE_JXL=OFF \
-DGDAL_USE_ICONV=ON \
-DGDAL_USE_JSONC=ON \
-DGDAL_USE_JSONC_INTERNAL=OFF \
-DGDAL_USE_ZLIB=ON \
-DGDAL_USE_ZLIB_INTERNAL=OFF \
-DGDAL_ENABLE_DRIVER_HDF5=ON \
-DGDAL_USE_HDF5=ON \
-DHDF5_INCLUDE_DIRS=$BUILD_PREFIX/include \
-DGDAL_ENABLE_DRIVER_NETCDF=ON \
-DGDAL_USE_NETCDF=ON \
-DGDAL_ENABLE_DRIVER_OPENJPEG=ON \
-DGDAL_ENABLE_DRIVER_PNG=ON \
-DGDAL_ENABLE_DRIVER_OGCAPI=OFF \
-DGDAL_USE_SQLITE3=ON \
-DOGR_ENABLE_DRIVER_SQLITE=ON \
-DOGR_ENABLE_DRIVER_GPKG=ON \
-DOGR_ENABLE_DRIVER_MVT=ON \
-DGDAL_ENABLE_DRIVER_MBTILES=ON \
-DOGR_ENABLE_DRIVER_OSM=ON \
-DBUILD_PYTHON_BINDINGS=OFF \
-DBUILD_JAVA_BINDINGS=OFF \
-DBUILD_CSHARP_BINDINGS=OFF \
-DGDAL_USE_SFCGAL=OFF \
-DGDAL_USE_XERCESC=OFF \
-DGDAL_USE_LIBXML2=OFF \
-DGDAL_USE_PCRE2=ON \
-DPCRE2_INCLUDE_DIR=$BUILD_PREFIX/include \
-DPCRE2-8_LIBRARY=$PCRE2_LIB \
-DGDAL_USE_POSTGRESQL=OFF \
-DGDAL_ENABLE_POSTGISRASTER=OFF \
-DGDAL_USE_OPENEXR=OFF \
-DGDAL_ENABLE_EXR=OFF \
-DGDAL_USE_OPENEXR=OFF \
-DGDAL_USE_HEIF=OFF \
-DGDAL_ENABLE_HEIF=OFF \
-DGDAL_USE_ODBC=OFF \
-DOGR_ENABLE_DRIVER_AVC=ON \
-DGDAL_ENABLE_DRIVER_AIGRID=ON \
-DGDAL_ENABLE_DRIVER_AAIGRID=ON \
-DGDAL_USE_LERC=ON \
-DGDAL_USE_LERC_INTERNAL=OFF \
-DGDAL_USE_PCRE2=OFF \
-DGDAL_USE_POSTGRESQL=OFF \
-DGDAL_USE_ODBC=OFF \
&& $cmake --build . -j4 \
&& $cmake --install .)
if [ -n "$IS_OSX" ]; then
:
else
strip -v --strip-unneeded ${BUILD_PREFIX}/lib/libgdal.so.* || true
strip -v --strip-unneeded ${BUILD_PREFIX}/lib64/libgdal.so.* || true
fi
touch gdal-stamp
}
function pre_build {
# Any stuff that you need to do before you start building the wheels
# Runs in the root directory of this repository.
#if [ -n "$IS_OSX" ]; then
# # Update to latest zlib for OSX build
# build_new_zlib
#fi
local cmake=$(get_modern_cmake)
build_openssl
suppress build_xz
suppress build_nghttp2
if [ -n "$IS_OSX" ]; then
rm /usr/local/lib/libpng* || true
fi
fetch_unpack https://curl.haxx.se/download/curl-${CURL_VERSION}.tar.gz
# Remove previously installed curl.
rm -rf /usr/local/lib/libcurl* || true
suppress build_curl
suppress build_libwebp
suppress build_zstd
suppress build_libpng
suppress build_jpeg
build_lerc
if [ -n "$IS_OSX" ]; then
export LDFLAGS="${LDFLAGS} -Wl,-rpath,${BUILD_PREFIX}/lib"
fi
build_tiff
suppress build_openjpeg
suppress build_jsonc
suppress build_sqlite
suppress build_proj
suppress build_expat
suppress build_geos
build_hdf5
build_netcdf
build_gdal
}
function run_tests {
unset GDAL_DATA
unset PROJ_DATA
if [ -n "$IS_OSX" ]; then
export PATH=$PATH:${BUILD_PREFIX}/bin
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
else
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
apt-get update
apt-get install -y ca-certificates
fi
cp -R ../rasterio/tests ./tests
python -m pip install $TEST_DEPENDS
PROJ_NETWORK=ON python -m pytest -vv tests -m "not gdalbin" -k "not test_ensure_env_decorator_sets_gdal_data_prefix and not test_tiled_dataset_blocksize_guard and not test_untiled_dataset_blocksize and not test_positional_calculation_byindex and not test_transform_geom_polygon and not test_reproject_error_propagation and not test_issue2353 and not test_info_azure_unsigned and not test_datasetreader_ctor_url and not test_outer_boundless_pixel_fidelity"
rio --version
rio env --formats
python ../test_fiona_issue383.py
}
function build_wheel_cmd {
local cmd=${1:-build_cmd}
local repo_dir=${2:-$REPO_DIR}
[ -z "$repo_dir" ] && echo "repo_dir not defined" && exit 1
local wheelhouse=$(abspath ${WHEEL_SDIR:-wheelhouse})
start_spinner
if [ -n "$(is_function "pre_build")" ]; then pre_build; fi
stop_spinner
pip install -U pip
pip install -U build
if [ -n "$BUILD_DEPENDS" ]; then
pip install $(pip_opts) $BUILD_DEPENDS
fi
(cd $repo_dir && GDAL_VERSION=3.9.1 $cmd $wheelhouse)
if [ -n "$IS_OSX" ]; then
pip install delocate
delocate-listdeps --all --depending $wheelhouse/*.whl
else # manylinux
pip install -I "auditwheel @ git+https://github.com/sgillies/auditwheel.git@extra-lib-name-tag"
fi
repair_wheelhouse $wheelhouse
}
function build_cmd {
local abs_wheelhouse=$1
python -m build -o $abs_wheelhouse
}
function macos_arm64_native_build_setup {
# Setup native build for single arch arm_64 wheels
export PLAT="arm64"
# We don't want universal2 builds and only want an arm64 build
export _PYTHON_HOST_PLATFORM="macosx-11.0-arm64"
export ARCHFLAGS+=" -arch arm64"
$@
}