python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / development / libraries / gdal / default.nix
blobbec478c66bd9323dc537fbce98c6cf47a46d5f65
1 { lib, stdenv, fetchFromGitHub, fetchpatch, unzip, libjpeg, libtiff, zlib, postgresql
2 , libmysqlclient, libgeotiff, pythonPackages, proj, geos, openssl, libpng
3 , sqlite, libspatialite, poppler, hdf4, qhull, giflib, expat, libiconv, libxml2
4 , autoreconfHook, netcdfSupport ? true, netcdf, hdf5, curl, pkg-config }:
6 with lib;
8 stdenv.mkDerivation rec {
9   pname = "gdal";
10   version = "3.4.2";
12   src = fetchFromGitHub {
13     owner = "OSGeo";
14     repo = "gdal";
15     rev = "v${version}";
16     sha256 = "sha256-bE55VV0SrG8nxCLdpODRalnuAkn+olRdMLUjduavj6M=";
17   };
19   sourceRoot = "source/gdal";
21   nativeBuildInputs = [ autoreconfHook pkg-config unzip ];
23   buildInputs = [
24     libjpeg
25     libtiff
26     libpng
27     proj
28     openssl
29     sqlite
30     libspatialite
31     libgeotiff
32     poppler
33     hdf4
34     qhull
35     giflib
36     expat
37     libxml2
38     postgresql
39   ] ++ (with pythonPackages; [ python setuptools numpy wrapPython ])
40     ++ lib.optional stdenv.isDarwin libiconv
41     ++ lib.optionals netcdfSupport [ netcdf hdf5 curl ];
43   configureFlags = [
44     "--with-expat=${expat.dev}"
45     "--with-jpeg=${libjpeg.dev}"
46     "--with-libtiff=${libtiff.dev}" # optional (without largetiff support)
47     "--with-png=${libpng.dev}" # optional
48     "--with-poppler=${poppler.dev}" # optional
49     "--with-libz=${zlib.dev}" # optional
50     "--with-pg=yes" # since gdal 3.0 doesn't use ${postgresql}/bin/pg_config
51     "--with-mysql=${getDev libmysqlclient}/bin/mysql_config"
52     "--with-geotiff=${libgeotiff}"
53     "--with-sqlite3=${sqlite.dev}"
54     "--with-spatialite=${libspatialite.dev}"
55     "--with-python" # optional
56     "--with-proj=${proj.dev}" # optional
57     "--with-geos=${geos}/bin/geos-config" # optional
58     "--with-hdf4=${hdf4.dev}" # optional
59     "--with-xml2=yes" # optional
60     (if netcdfSupport then "--with-netcdf=${netcdf}" else "")
61   ];
63   hardeningDisable = [ "format" ];
65   CXXFLAGS = lib.concatStringsSep " " [
66     "-fpermissive"
67     # poppler uses std::optional
68     "-std=c++17"
69   ];
71   # - Unset CC and CXX as they confuse libtool.
72   # - teach gdal that libdf is the legacy name for libhdf
73   preConfigure = ''
74     substituteInPlace configure \
75       --replace "-lmfhdf -ldf" "-lmfhdf -lhdf"
76   '';
78   preBuild = ''
79     substituteInPlace swig/python/GNUmakefile \
80       --replace "ifeq (\$(STD_UNIX_LAYOUT),\"TRUE\")" "ifeq (1,1)"
81   '';
83   postInstall = ''
84     wrapPythonPrograms
85   '';
87   enableParallelBuilding = true;
89   doInstallCheck = true;
90   # preCheck rather than preInstallCheck because this is what pytestCheckHook
91   # calls (coming from the python world)
92   preCheck = ''
93     pushd ../autotest
94     # something has made files here read-only by this point
95     chmod -R u+w .
97     export HOME=$(mktemp -d)
98     export PYTHONPATH="$out/${pythonPackages.python.sitePackages}:$PYTHONPATH"
99   '';
100   installCheckInputs = with pythonPackages; [
101     pytestCheckHook
102     pytest-env
103     lxml
104   ];
105   disabledTestPaths = [
106     # tests that attempt to make network requests
107     "gcore/vsis3.py"
108     "gdrivers/gdalhttp.py"
109     "gdrivers/wms.py"
110   ];
111   disabledTests = [
112     # tests that attempt to make network requests
113     "test_jp2openjpeg_45"
114     # tests that require the full proj dataset which we don't package yet
115     # https://github.com/OSGeo/gdal/issues/5523
116     "test_transformer_dem_overrride_srs"
117     "test_osr_ct_options_area_of_interest"
118   ] ++ lib.optionals (!stdenv.isx86_64) [
119     # likely precision-related expecting x87 behaviour
120     "test_jp2openjpeg_22"
121   ] ++ lib.optionals stdenv.isDarwin [
122     # flaky on macos
123     "test_rda_download_queue"
124   ];
125   postCheck = ''
126     popd # ../autotest
127   '';
129   meta = {
130     description = "Translator library for raster geospatial data formats";
131     homepage = "https://www.gdal.org/";
132     license = lib.licenses.mit;
133     maintainers = [ lib.maintainers.marcweber ];
134     platforms = with lib.platforms; linux ++ darwin;
135   };