emacsPackages.lsp-bridge: 0-unstable-2025-01-11 -> 0-unstable-2025-01-22 (#376531)
[NixPkgs.git] / pkgs / development / python-modules / python-mapnik / default.nix
blob33770c3d82917f5f246861fa6ec762594ce37504
2   lib,
3   buildPythonPackage,
4   fetchFromGitHub,
5   substituteAll,
6   isPyPy,
7   python,
8   setuptools,
9   pillow,
10   pycairo,
11   pkg-config,
12   boost,
13   cairo,
14   harfbuzz,
15   icu,
16   libjpeg,
17   libpng,
18   libtiff,
19   libwebp,
20   mapnik,
21   proj,
22   zlib,
23   libxml2,
24   sqlite,
25   pytestCheckHook,
26   darwin,
27   sparsehash,
30 buildPythonPackage rec {
31   pname = "python-mapnik";
32   version = "3.0.16-unstable-2024-02-22";
33   pyproject = true;
35   src = fetchFromGitHub {
36     owner = "mapnik";
37     repo = "python-mapnik";
38     rev = "5ab32f0209909cc98c26e1d86ce0c8ef29a9bf3d";
39     hash = "sha256-OqijA1WcyBcyWO8gntqp+xNIaV1Jqa0n1eMDip2OCvY=";
40     # Only needed for test data
41     fetchSubmodules = true;
42   };
44   patches = [
45     # python-mapnik seems to depend on having the mapnik src directory
46     # structure available at build time. We just hardcode the paths.
47     (substituteAll {
48       src = ./find-libmapnik.patch;
49       libmapnik = "${mapnik}/lib";
50     })
51     # Use `std::optional` rather than `boost::optional`
52     # https://github.com/mapnik/python-mapnik/commit/e9f88a95a03dc081826a69da67bbec3e4cccd5eb
53     ./python-mapnik_std_optional.patch
54   ];
56   stdenv = python.stdenv;
58   build-system = [ setuptools ];
60   nativeBuildInputs = [
61     mapnik # for mapnik_config
62     pkg-config
63   ];
65   dependencies = [
66     mapnik
67     boost
68     cairo
69     harfbuzz
70     icu
71     libjpeg
72     libpng
73     libtiff
74     libwebp
75     proj
76     zlib
77     libxml2
78     sqlite
79     sparsehash
80   ];
82   propagatedBuildInputs = [
83     pillow
84     pycairo
85   ];
87   configureFlags = [ "XMLPARSER=libxml2" ];
89   disabled = isPyPy;
91   preBuild = ''
92     export BOOST_PYTHON_LIB="boost_python${"${lib.versions.major python.version}${lib.versions.minor python.version}"}"
93     export BOOST_THREAD_LIB="boost_thread"
94     export BOOST_SYSTEM_LIB="boost_system"
95     export PYCAIRO=true
96     export XMLPARSER=libxml2
97   '';
99   nativeCheckInputs = [ pytestCheckHook ];
101   preCheck =
102     ''
103       # import from $out
104       rm -r mapnik
105     ''
106     + lib.optionalString stdenv.hostPlatform.isDarwin ''
107       # Replace the hardcoded /tmp references with $TMPDIR
108       sed -i "s,/tmp,$TMPDIR,g" test/python_tests/*.py
109     '';
111   # https://github.com/mapnik/python-mapnik/issues/255
112   disabledTests =
113     [
114       "test_geometry_type"
115       "test_passing_pycairo_context_pdf"
116       "test_pdf_printing"
117       "test_render_with_scale_factor"
118     ]
119     ++ lib.optionals stdenv.hostPlatform.isDarwin [
120       "test_passing_pycairo_context_png"
121       "test_passing_pycairo_context_svg"
122       "test_pycairo_pdf_surface1"
123       "test_pycairo_pdf_surface2"
124       "test_pycairo_pdf_surface3"
125       "test_pycairo_svg_surface1"
126       "test_pycairo_svg_surface2"
127       "test_pycairo_svg_surface3"
128     ];
130   pythonImportsCheck = [ "mapnik" ];
132   meta = with lib; {
133     description = "Python bindings for Mapnik";
134     maintainers = [ ];
135     homepage = "https://mapnik.org";
136     license = licenses.lgpl21Plus;
137     broken = true; # At 2024-11-13, test_raster_warping fails.
138   };