2022-11-21 17:40:18 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2023-08-04 22:07:22 +00:00
|
|
|
, callPackage
|
2022-11-21 17:40:18 +00:00
|
|
|
, fetchFromGitHub
|
2024-04-21 15:54:59 +00:00
|
|
|
, fetchpatch
|
2023-08-04 22:07:22 +00:00
|
|
|
|
2023-08-22 20:05:09 +00:00
|
|
|
, useMinimalFeatures ? false
|
|
|
|
, useTiledb ? (!useMinimalFeatures) && !(stdenv.isDarwin && stdenv.isx86_64)
|
|
|
|
, useLibHEIF ? (!useMinimalFeatures)
|
|
|
|
, useLibJXL ? (!useMinimalFeatures)
|
|
|
|
, useMysql ? (!useMinimalFeatures)
|
|
|
|
, usePostgres ? (!useMinimalFeatures)
|
|
|
|
, usePoppler ? (!useMinimalFeatures)
|
|
|
|
, useArrow ? (!useMinimalFeatures)
|
|
|
|
, useHDF ? (!useMinimalFeatures)
|
|
|
|
, useNetCDF ? (!useMinimalFeatures)
|
|
|
|
, useArmadillo ? (!useMinimalFeatures)
|
2024-02-07 01:22:34 +00:00
|
|
|
, useJava ? (!useMinimalFeatures)
|
2023-08-22 20:05:09 +00:00
|
|
|
|
2024-02-07 01:22:34 +00:00
|
|
|
, ant
|
2022-11-21 17:40:18 +00:00
|
|
|
, bison
|
|
|
|
, cmake
|
2023-07-15 17:15:38 +00:00
|
|
|
, gtest
|
2022-11-21 17:40:18 +00:00
|
|
|
, doxygen
|
|
|
|
, graphviz
|
|
|
|
, pkg-config
|
|
|
|
, python3
|
|
|
|
, swig
|
|
|
|
, armadillo
|
|
|
|
, arrow-cpp
|
|
|
|
, c-blosc
|
|
|
|
, brunsli
|
|
|
|
, cfitsio
|
|
|
|
, crunch
|
|
|
|
, curl
|
|
|
|
, cryptopp
|
|
|
|
, libdeflate
|
|
|
|
, expat
|
|
|
|
, libgeotiff
|
|
|
|
, geos
|
|
|
|
, giflib
|
2024-02-07 01:22:34 +00:00
|
|
|
, jdk
|
2022-11-21 17:40:18 +00:00
|
|
|
, libheif
|
|
|
|
, dav1d
|
|
|
|
, libaom
|
|
|
|
, libde265
|
|
|
|
, rav1e
|
|
|
|
, x265
|
|
|
|
, hdf4
|
|
|
|
, hdf5-cpp
|
|
|
|
, libiconv
|
|
|
|
, libjpeg
|
|
|
|
, json_c
|
|
|
|
, libjxl
|
|
|
|
, libhwy
|
|
|
|
, lerc
|
|
|
|
, xz
|
|
|
|
, libxml2
|
|
|
|
, lz4
|
|
|
|
, libmysqlclient
|
|
|
|
, netcdf
|
|
|
|
, openexr
|
|
|
|
, openjpeg
|
|
|
|
, openssl
|
|
|
|
, pcre2
|
|
|
|
, libpng
|
|
|
|
, poppler
|
|
|
|
, postgresql
|
|
|
|
, proj
|
|
|
|
, qhull
|
|
|
|
, libspatialite
|
|
|
|
, sqlite
|
|
|
|
, libtiff
|
|
|
|
, tiledb
|
|
|
|
, libwebp
|
|
|
|
, xercesc
|
|
|
|
, zlib
|
|
|
|
, zstd
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2024-06-20 14:57:18 +00:00
|
|
|
pname = "gdal" + lib.optionalString useMinimalFeatures "-minimal";
|
|
|
|
version = "3.9.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "OSGeo";
|
|
|
|
repo = "gdal";
|
2023-08-04 22:07:22 +00:00
|
|
|
rev = "v${finalAttrs.version}";
|
2024-06-20 14:57:18 +00:00
|
|
|
hash = "sha256-xEekgF9GzsPYkwk7Nny9b1DMLTxBqTSdudYxaz4jl/c=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
patches = [
|
2024-06-20 14:57:18 +00:00
|
|
|
# HDF5: add support for libhdf5 >= 1.14.4.2 when built with Float16
|
2024-04-21 15:54:59 +00:00
|
|
|
(fetchpatch {
|
2024-06-20 14:57:18 +00:00
|
|
|
url = "https://github.com/OSGeo/gdal/commit/16ade8253f26200246abb5ab24d17e18216e7a11.patch";
|
|
|
|
sha256 = "sha256-N6YqfcOUWeaJXVE9RUo1dzulxqIY5Q/UygPnZHau3Lc=";
|
2024-04-21 15:54:59 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
bison
|
|
|
|
cmake
|
|
|
|
doxygen
|
|
|
|
graphviz
|
|
|
|
pkg-config
|
|
|
|
python3.pkgs.setuptools
|
|
|
|
python3.pkgs.wrapPython
|
|
|
|
swig
|
2024-02-07 01:22:34 +00:00
|
|
|
] ++ lib.optionals useJava [ ant jdk ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DGDAL_USE_INTERNAL_LIBS=OFF"
|
|
|
|
"-DGEOTIFF_INCLUDE_DIR=${lib.getDev libgeotiff}/include"
|
|
|
|
"-DGEOTIFF_LIBRARY_RELEASE=${lib.getLib libgeotiff}/lib/libgeotiff${stdenv.hostPlatform.extensions.sharedLibrary}"
|
|
|
|
"-DMYSQL_INCLUDE_DIR=${lib.getDev libmysqlclient}/include/mysql"
|
2023-02-02 18:25:31 +00:00
|
|
|
"-DMYSQL_LIBRARY=${lib.getLib libmysqlclient}/lib/${lib.optionalString (libmysqlclient.pname != "mysql") "mysql/"}libmysqlclient${stdenv.hostPlatform.extensions.sharedLibrary}"
|
2023-08-04 22:07:22 +00:00
|
|
|
] ++ lib.optionals finalAttrs.doInstallCheck [
|
2023-07-15 17:15:38 +00:00
|
|
|
"-DBUILD_TESTING=ON"
|
2022-11-21 17:40:18 +00:00
|
|
|
] ++ lib.optionals (!stdenv.isDarwin) [
|
|
|
|
"-DCMAKE_SKIP_BUILD_RPATH=ON" # without, libgdal.so can't find libmariadb.so
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
"-DCMAKE_BUILD_WITH_INSTALL_NAME_DIR=ON"
|
2023-05-24 13:37:59 +00:00
|
|
|
] ++ lib.optionals (!useTiledb) [
|
|
|
|
"-DGDAL_USE_TILEDB=OFF"
|
2024-02-07 01:22:34 +00:00
|
|
|
] ++ lib.optionals (!useJava) [
|
|
|
|
# This is not strictly needed as the Java bindings wouldn't build anyway if
|
|
|
|
# ant/jdk were not available.
|
|
|
|
"-DBUILD_JAVA_BINDINGS=OFF"
|
2022-11-21 17:40:18 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-08-22 20:05:09 +00:00
|
|
|
buildInputs =
|
|
|
|
let
|
|
|
|
tileDbDeps = lib.optionals useTiledb [ tiledb ];
|
|
|
|
libHeifDeps = lib.optionals useLibHEIF [
|
|
|
|
libheif
|
|
|
|
dav1d
|
|
|
|
libaom
|
|
|
|
libde265
|
|
|
|
rav1e
|
|
|
|
x265
|
|
|
|
];
|
|
|
|
libJxlDeps = lib.optionals useLibJXL [
|
|
|
|
libjxl
|
|
|
|
libhwy
|
|
|
|
];
|
|
|
|
mysqlDeps = lib.optionals useMysql [ libmysqlclient ];
|
|
|
|
postgresDeps = lib.optionals usePostgres [ postgresql ];
|
|
|
|
popplerDeps = lib.optionals usePoppler [ poppler ];
|
|
|
|
arrowDeps = lib.optionals useArrow [ arrow-cpp ];
|
|
|
|
hdfDeps = lib.optionals useHDF [
|
|
|
|
hdf4
|
|
|
|
hdf5-cpp
|
|
|
|
];
|
|
|
|
netCdfDeps = lib.optionals useNetCDF [ netcdf ];
|
|
|
|
armadilloDeps = lib.optionals useArmadillo [ armadillo ];
|
|
|
|
|
|
|
|
darwinDeps = lib.optionals stdenv.isDarwin [ libiconv ];
|
|
|
|
nonDarwinDeps = lib.optionals (!stdenv.isDarwin) ([
|
|
|
|
# tests for formats enabled by these packages fail on macos
|
|
|
|
openexr
|
|
|
|
xercesc
|
|
|
|
] ++ arrowDeps);
|
2024-02-07 01:22:34 +00:00
|
|
|
in
|
|
|
|
[
|
2023-08-22 20:05:09 +00:00
|
|
|
c-blosc
|
|
|
|
brunsli
|
|
|
|
cfitsio
|
|
|
|
crunch
|
|
|
|
curl
|
|
|
|
cryptopp
|
|
|
|
libdeflate
|
|
|
|
expat
|
|
|
|
libgeotiff
|
|
|
|
geos
|
|
|
|
giflib
|
|
|
|
libjpeg
|
|
|
|
json_c
|
|
|
|
lerc
|
|
|
|
xz
|
|
|
|
libxml2
|
|
|
|
lz4
|
|
|
|
openjpeg
|
|
|
|
openssl
|
|
|
|
pcre2
|
|
|
|
libpng
|
|
|
|
proj
|
|
|
|
qhull
|
|
|
|
libspatialite
|
|
|
|
sqlite
|
|
|
|
libtiff
|
|
|
|
gtest
|
|
|
|
libwebp
|
|
|
|
zlib
|
|
|
|
zstd
|
|
|
|
python3
|
|
|
|
python3.pkgs.numpy
|
|
|
|
] ++ tileDbDeps
|
2024-02-07 01:22:34 +00:00
|
|
|
++ libHeifDeps
|
|
|
|
++ libJxlDeps
|
|
|
|
++ mysqlDeps
|
|
|
|
++ postgresDeps
|
|
|
|
++ popplerDeps
|
|
|
|
++ arrowDeps
|
|
|
|
++ hdfDeps
|
|
|
|
++ netCdfDeps
|
|
|
|
++ armadilloDeps
|
|
|
|
++ darwinDeps
|
|
|
|
++ nonDarwinDeps;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
pythonPath = [ python3.pkgs.numpy ];
|
2020-04-24 23:36:52 +00:00
|
|
|
postInstall = ''
|
2024-02-29 20:09:43 +00:00
|
|
|
wrapPythonProgramsIn "$out/bin" "$out $pythonPath"
|
2024-02-07 01:22:34 +00:00
|
|
|
'' + lib.optionalString useJava ''
|
|
|
|
cd $out/lib
|
|
|
|
ln -s ./jni/libgdalalljni${stdenv.hostPlatform.extensions.sharedLibrary}
|
|
|
|
cd -
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
doInstallCheck = true;
|
|
|
|
# preCheck rather than preInstallCheck because this is what pytestCheckHook
|
|
|
|
# calls (coming from the python world)
|
|
|
|
preCheck = ''
|
2023-07-15 17:15:38 +00:00
|
|
|
pushd autotest
|
2022-04-15 01:41:22 +00:00
|
|
|
|
|
|
|
export HOME=$(mktemp -d)
|
2022-11-21 17:40:18 +00:00
|
|
|
export PYTHONPATH="$out/${python3.sitePackages}:$PYTHONPATH"
|
2023-07-15 17:15:38 +00:00
|
|
|
export GDAL_DOWNLOAD_TEST_DATA=OFF
|
|
|
|
# allows to skip tests that fail because of file handle leak
|
|
|
|
# the issue was not investigated
|
2024-06-20 14:57:18 +00:00
|
|
|
# https://github.com/OSGeo/gdal/blob/v3.9.0/autotest/gdrivers/bag.py#L54
|
|
|
|
export CI=1
|
2022-04-15 01:41:22 +00:00
|
|
|
'';
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeInstallCheckInputs = with python3.pkgs; [
|
2022-04-15 01:41:22 +00:00
|
|
|
pytestCheckHook
|
2024-04-21 15:54:59 +00:00
|
|
|
pytest-benchmark
|
2022-04-15 01:41:22 +00:00
|
|
|
pytest-env
|
2023-07-15 17:15:38 +00:00
|
|
|
filelock
|
2022-04-15 01:41:22 +00:00
|
|
|
lxml
|
|
|
|
];
|
2024-04-21 15:54:59 +00:00
|
|
|
pytestFlagsArray = [
|
|
|
|
"--benchmark-disable"
|
|
|
|
];
|
2022-04-15 01:41:22 +00:00
|
|
|
disabledTestPaths = [
|
|
|
|
# tests that attempt to make network requests
|
|
|
|
"gcore/vsis3.py"
|
|
|
|
"gdrivers/gdalhttp.py"
|
|
|
|
"gdrivers/wms.py"
|
|
|
|
];
|
|
|
|
disabledTests = [
|
|
|
|
# tests that attempt to make network requests
|
|
|
|
"test_jp2openjpeg_45"
|
|
|
|
# tests that require the full proj dataset which we don't package yet
|
|
|
|
# https://github.com/OSGeo/gdal/issues/5523
|
|
|
|
"test_transformer_dem_overrride_srs"
|
|
|
|
"test_osr_ct_options_area_of_interest"
|
2022-11-21 17:40:18 +00:00
|
|
|
# ZIP does not support timestamps before 1980
|
2023-07-15 17:15:38 +00:00
|
|
|
"test_sentinel2_zipped"
|
2023-03-15 16:39:30 +00:00
|
|
|
# tries to call unwrapped executable
|
|
|
|
"test_SetPROJAuxDbPaths"
|
2023-11-16 04:20:00 +00:00
|
|
|
# fixed and renamed in 3.8.0RC1
|
|
|
|
# https://github.com/OSGeo/gdal/commit/c8b471ca1e6318866ff668d2b57bb6f076e3ae29
|
|
|
|
"test_visoss_6"
|
2024-01-02 11:29:13 +00:00
|
|
|
# failing with PROJ 9.3.1
|
|
|
|
# https://github.com/OSGeo/gdal/issues/8908
|
|
|
|
"test_osr_esri_28"
|
2022-04-15 01:41:22 +00:00
|
|
|
] ++ lib.optionals (!stdenv.isx86_64) [
|
|
|
|
# likely precision-related expecting x87 behaviour
|
|
|
|
"test_jp2openjpeg_22"
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
# flaky on macos
|
|
|
|
"test_rda_download_queue"
|
2022-11-21 17:40:18 +00:00
|
|
|
] ++ lib.optionals (lib.versionOlder proj.version "8") [
|
|
|
|
"test_ogr_parquet_write_crs_without_id_in_datum_ensemble_members"
|
2023-08-22 20:05:09 +00:00
|
|
|
] ++ lib.optionals (!usePoppler) [
|
|
|
|
"test_pdf_jpx_compression"
|
2022-04-15 01:41:22 +00:00
|
|
|
];
|
|
|
|
postCheck = ''
|
2023-07-15 17:15:38 +00:00
|
|
|
popd # autotest
|
2022-04-15 01:41:22 +00:00
|
|
|
'';
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
passthru.tests = callPackage ./tests.nix { gdal = finalAttrs.finalPackage; };
|
2023-08-04 22:07:22 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
__darwinAllowLocalNetworking = true;
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
meta = with lib; {
|
2023-08-04 22:07:22 +00:00
|
|
|
changelog = "https://github.com/OSGeo/gdal/blob/v${finalAttrs.version}/NEWS.md";
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Translator library for raster geospatial data formats";
|
|
|
|
homepage = "https://www.gdal.org/";
|
2023-07-15 17:15:38 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; teams.geospatial.members ++ [ marcweber dotlambda ];
|
|
|
|
platforms = platforms.unix;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2023-08-04 22:07:22 +00:00
|
|
|
})
|