rdma-core: 54.0 -> 55.0 (#364655)
[NixPkgs.git] / pkgs / development / libraries / gdal / default.nix
blobdd589ddd7eaa3320653e5ea3027da22d82b15fbf
2   lib,
3   stdenv,
4   callPackage,
5   fetchFromGitHub,
7   useMinimalFeatures ? false,
8   useArmadillo ? (!useMinimalFeatures),
9   useArrow ? (!useMinimalFeatures),
10   useHDF ? (!useMinimalFeatures),
11   useJava ? (!useMinimalFeatures),
12   useLibAvif ? (!useMinimalFeatures),
13   useLibHEIF ? (!useMinimalFeatures),
14   useLibJXL ? (!useMinimalFeatures),
15   useMysql ? (!useMinimalFeatures),
16   useNetCDF ? (!useMinimalFeatures),
17   usePoppler ? (!useMinimalFeatures),
18   usePostgres ? (!useMinimalFeatures),
19   useTiledb ?
20     (!useMinimalFeatures) && !(stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64),
22   ant,
23   armadillo,
24   arrow-cpp,
25   bison,
26   brunsli,
27   c-blosc,
28   cfitsio,
29   cmake,
30   crunch,
31   cryptopp,
32   curl,
33   dav1d,
34   doxygen,
35   expat,
36   geos,
37   giflib,
38   graphviz,
39   gtest,
40   hdf4,
41   hdf5-cpp,
42   jdk,
43   json_c,
44   lerc,
45   libaom,
46   libavif,
47   libde265,
48   libdeflate,
49   libgeotiff,
50   libheif,
51   libhwy,
52   libiconv,
53   libjpeg,
54   libjxl,
55   libmysqlclient,
56   libpng,
57   libspatialite,
58   libtiff,
59   libwebp,
60   libxml2,
61   lz4,
62   netcdf,
63   openexr,
64   openjpeg,
65   openssl,
66   pcre2,
67   pkg-config,
68   poppler,
69   postgresql,
70   proj,
71   python3,
72   qhull,
73   rav1e,
74   sqlite,
75   swig,
76   tiledb,
77   x265,
78   xercesc,
79   xz,
80   zlib,
81   zstd,
84 stdenv.mkDerivation (finalAttrs: {
85   pname = "gdal" + lib.optionalString useMinimalFeatures "-minimal";
86   version = "3.10.0";
88   src = fetchFromGitHub {
89     owner = "OSGeo";
90     repo = "gdal";
91     rev = "v${finalAttrs.version}";
92     hash = "sha256-pb2xKTmJB7U1jIG80ENmZrR7vFw6YDoees43u/JhU3Y=";
93   };
95   nativeBuildInputs =
96     [
97       bison
98       cmake
99       doxygen
100       graphviz
101       pkg-config
102       python3.pkgs.setuptools
103       python3.pkgs.wrapPython
104       swig
105     ]
106     ++ lib.optionals useJava [
107       ant
108       jdk
109     ];
111   cmakeFlags =
112     [
113       "-DGDAL_USE_INTERNAL_LIBS=OFF"
114       "-DGEOTIFF_INCLUDE_DIR=${lib.getDev libgeotiff}/include"
115       "-DGEOTIFF_LIBRARY_RELEASE=${lib.getLib libgeotiff}/lib/libgeotiff${stdenv.hostPlatform.extensions.sharedLibrary}"
116       "-DMYSQL_INCLUDE_DIR=${lib.getDev libmysqlclient}/include/mysql"
117       "-DMYSQL_LIBRARY=${lib.getLib libmysqlclient}/lib/${
118         lib.optionalString (libmysqlclient.pname != "mysql") "mysql/"
119       }libmysqlclient${stdenv.hostPlatform.extensions.sharedLibrary}"
120     ]
121     ++ lib.optionals finalAttrs.doInstallCheck [
122       "-DBUILD_TESTING=ON"
123     ]
124     ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
125       "-DCMAKE_SKIP_BUILD_RPATH=ON" # without, libgdal.so can't find libmariadb.so
126     ]
127     ++ lib.optionals stdenv.hostPlatform.isDarwin [
128       "-DCMAKE_BUILD_WITH_INSTALL_NAME_DIR=ON"
129     ]
130     ++ lib.optionals (!useTiledb) [
131       "-DGDAL_USE_TILEDB=OFF"
132     ]
133     ++ lib.optionals (!useJava) [
134       # This is not strictly needed as the Java bindings wouldn't build anyway if
135       # ant/jdk were not available.
136       "-DBUILD_JAVA_BINDINGS=OFF"
137     ];
139   buildInputs =
140     let
141       tileDbDeps = lib.optionals useTiledb [ tiledb ];
142       libAvifDeps = lib.optionals useLibAvif [ libavif ];
143       libHeifDeps = lib.optionals useLibHEIF [
144         libheif
145         dav1d
146         libaom
147         libde265
148         rav1e
149         x265
150       ];
151       libJxlDeps = lib.optionals useLibJXL [
152         libjxl
153         libhwy
154       ];
155       mysqlDeps = lib.optionals useMysql [ libmysqlclient ];
156       postgresDeps = lib.optionals usePostgres [ postgresql ];
157       popplerDeps = lib.optionals usePoppler [ poppler ];
158       arrowDeps = lib.optionals useArrow [ arrow-cpp ];
159       hdfDeps = lib.optionals useHDF [
160         hdf4
161         hdf5-cpp
162       ];
163       netCdfDeps = lib.optionals useNetCDF [ netcdf ];
164       armadilloDeps = lib.optionals useArmadillo [ armadillo ];
166       darwinDeps = lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ];
167       nonDarwinDeps = lib.optionals (!stdenv.hostPlatform.isDarwin) (
168         [
169           # tests for formats enabled by these packages fail on macos
170           openexr
171           xercesc
172         ]
173         ++ arrowDeps
174       );
175     in
176     [
177       c-blosc
178       brunsli
179       cfitsio
180       crunch
181       curl
182       cryptopp
183       libdeflate
184       expat
185       libgeotiff
186       geos
187       giflib
188       libjpeg
189       json_c
190       lerc
191       xz
192       (libxml2.override { enableHttp = true; })
193       lz4
194       openjpeg
195       openssl
196       pcre2
197       libpng
198       proj
199       qhull
200       libspatialite
201       sqlite
202       libtiff
203       gtest
204       libwebp
205       zlib
206       zstd
207       python3
208       python3.pkgs.numpy
209     ]
210     ++ tileDbDeps
211     ++ libAvifDeps
212     ++ libHeifDeps
213     ++ libJxlDeps
214     ++ mysqlDeps
215     ++ postgresDeps
216     ++ popplerDeps
217     ++ arrowDeps
218     ++ hdfDeps
219     ++ netCdfDeps
220     ++ armadilloDeps
221     ++ darwinDeps
222     ++ nonDarwinDeps;
224   pythonPath = [ python3.pkgs.numpy ];
225   postInstall =
226     ''
227       wrapPythonProgramsIn "$out/bin" "$out $pythonPath"
228     ''
229     + lib.optionalString useJava ''
230       cd $out/lib
231       ln -s ./jni/libgdalalljni${stdenv.hostPlatform.extensions.sharedLibrary}
232       cd -
233     '';
235   enableParallelBuilding = true;
237   doInstallCheck = true;
238   # preCheck rather than preInstallCheck because this is what pytestCheckHook
239   # calls (coming from the python world)
240   preCheck = ''
241     pushd autotest
243     export HOME=$(mktemp -d)
244     export PYTHONPATH="$out/${python3.sitePackages}:$PYTHONPATH"
245     export GDAL_DOWNLOAD_TEST_DATA=OFF
246     # allows to skip tests that fail because of file handle leak
247     # the issue was not investigated
248     # https://github.com/OSGeo/gdal/blob/v3.9.0/autotest/gdrivers/bag.py#L54
249     export CI=1
250   '';
251   nativeInstallCheckInputs = with python3.pkgs; [
252     pytestCheckHook
253     pytest-benchmark
254     pytest-env
255     filelock
256     lxml
257   ];
258   pytestFlagsArray = [
259     "--benchmark-disable"
260   ];
261   disabledTestPaths = [
262     # tests that attempt to make network requests
263     "gcore/vsis3.py"
264     "gdrivers/gdalhttp.py"
265     "gdrivers/wms.py"
266   ];
267   disabledTests =
268     [
269       # tests that attempt to make network requests
270       "test_jp2openjpeg_45"
271       # tests that require the full proj dataset which we don't package yet
272       # https://github.com/OSGeo/gdal/issues/5523
273       "test_transformer_dem_overrride_srs"
274       "test_osr_ct_options_area_of_interest"
275       # ZIP does not support timestamps before 1980
276       "test_sentinel2_zipped"
277       # tries to call unwrapped executable
278       "test_SetPROJAuxDbPaths"
279       # failing for unknown reason
280       # https://github.com/OSGeo/gdal/pull/10806#issuecomment-2362054085
281       "test_ogr_gmlas_billion_laugh"
282       # Flaky on hydra, collected in https://github.com/NixOS/nixpkgs/pull/327323.
283       "test_ogr_gmlas_huge_processing_time"
284       "test_ogr_gpkg_background_rtree_build"
285       "test_vsiaz_fake_write"
286       "test_vsioss_6"
287     ]
288     ++ lib.optionals (!stdenv.hostPlatform.isx86_64) [
289       # likely precision-related expecting x87 behaviour
290       "test_jp2openjpeg_22"
291     ]
292     ++ lib.optionals stdenv.hostPlatform.isDarwin [
293       # flaky on macos
294       "test_rda_download_queue"
295     ]
296     ++ lib.optionals (lib.versionOlder proj.version "8") [
297       "test_ogr_parquet_write_crs_without_id_in_datum_ensemble_members"
298     ]
299     ++ lib.optionals (!usePoppler) [
300       "test_pdf_jpx_compression"
301     ];
302   postCheck = ''
303     popd # autotest
304   '';
306   passthru.tests = callPackage ./tests.nix { gdal = finalAttrs.finalPackage; };
308   __darwinAllowLocalNetworking = true;
310   meta = with lib; {
311     changelog = "https://github.com/OSGeo/gdal/blob/v${finalAttrs.version}/NEWS.md";
312     description = "Translator library for raster geospatial data formats";
313     homepage = "https://www.gdal.org/";
314     license = licenses.mit;
315     maintainers =
316       with maintainers;
317       teams.geospatial.members
318       ++ [
319         marcweber
320         dotlambda
321       ];
322     platforms = platforms.unix;
323   };