1{ lib 2, buildPythonPackage 3, fetchFromGitHub 4, fetchpatch 5, substituteAll 6, isPyPy 7, python 8, pillow 9, pycairo 10, pkg-config 11, boost182 12, cairo 13, harfbuzz 14, icu 15, libjpeg 16, libpng 17, libtiff 18, libwebp 19, mapnik 20, proj 21, zlib 22, libxml2 23, sqlite 24, nose 25, pytestCheckHook 26, stdenv 27}: 28 29buildPythonPackage rec { 30 pname = "python-mapnik"; 31 version = "unstable-2020-09-08"; 32 33 src = fetchFromGitHub { 34 owner = "mapnik"; 35 repo = "python-mapnik"; 36 rev = "a2c2a86eec954b42d7f00093da03807d0834b1b4"; 37 hash = "sha256-GwDdrutJOHtW7pIWiUAiu1xucmRvp7YFYB3YSCrDsrY="; 38 # Only needed for test data 39 fetchSubmodules = true; 40 }; 41 42 patches = [ 43 # https://github.com/mapnik/python-mapnik/issues/239 44 (fetchpatch { 45 url = "https://github.com/koordinates/python-mapnik/commit/318b1edac16f48a7f21902c192c1dd86f6210a44.patch"; 46 hash = "sha256-cfU8ZqPPGCqoHEyGvJ8Xy/bGpbN2vSDct6A3N5+I8xM="; 47 }) 48 ./find-pycairo-with-pkg-config.patch 49 # python-mapnik seems to depend on having the mapnik src directory 50 # structure available at build time. We just hardcode the paths. 51 (substituteAll { 52 src = ./find-libmapnik.patch; 53 libmapnik = "${mapnik}/lib"; 54 }) 55 ]; 56 57 nativeBuildInputs = [ 58 mapnik # for mapnik_config 59 pkg-config 60 ]; 61 62 buildInputs = [ 63 mapnik 64 boost182 65 cairo 66 harfbuzz 67 icu 68 libjpeg 69 libpng 70 libtiff 71 libwebp 72 proj 73 zlib 74 libxml2 75 sqlite 76 ]; 77 78 propagatedBuildInputs = [ pillow pycairo ]; 79 80 configureFlags = [ 81 "XMLPARSER=libxml2" 82 ]; 83 84 disabled = isPyPy; 85 86 preBuild = '' 87 export BOOST_PYTHON_LIB="boost_python${"${lib.versions.major python.version}${lib.versions.minor python.version}"}" 88 export BOOST_THREAD_LIB="boost_thread" 89 export BOOST_SYSTEM_LIB="boost_system" 90 export PYCAIRO=true 91 export XMLPARSER=libxml2 92 ''; 93 94 nativeCheckInputs = [ 95 nose 96 pytestCheckHook 97 ]; 98 99 preCheck = '' 100 # import from $out 101 rm -r mapnik 102 '' + lib.optionalString stdenv.isDarwin '' 103 # Replace the hardcoded /tmp references with $TMPDIR 104 sed -i "s,/tmp,$TMPDIR,g" test/python_tests/*.py 105 ''; 106 107 # https://github.com/mapnik/python-mapnik/issues/255 108 disabledTests = [ 109 "test_adding_datasource_to_layer" 110 "test_compare_map" 111 "test_dataraster_coloring" 112 "test_dataraster_query_point" 113 "test_geometry_type" 114 "test_good_files" 115 "test_layer_init" 116 "test_load_save_map" 117 "test_loading_fontset_from_map" 118 "test_normalizing_definition" 119 "test_pdf_printing" 120 "test_proj_antimeridian_bbox" 121 "test_proj_transform_between_init_and_literal" 122 "test_pycairo_pdf_surface1" 123 "test_pycairo_svg_surface1" 124 "test_query_tolerance" 125 "test_raster_warping" 126 "test_raster_warping_does_not_overclip_source" 127 "test_render_points" 128 "test_render_with_scale_factor" 129 "test_style_level_image_filter" 130 "test_that_coordinates_do_not_overflow_and_polygon_is_rendered_csv" 131 "test_that_coordinates_do_not_overflow_and_polygon_is_rendered_memory" 132 "test_transparency_levels" 133 "test_visual_zoom_all_rendering1" 134 "test_visual_zoom_all_rendering2" 135 "test_wgs84_inverse_forward" 136 ] ++ lib.optionals stdenv.isDarwin [ 137 "test_passing_pycairo_context_pdf" 138 ]; 139 140 pythonImportsCheck = [ "mapnik" ]; 141 142 meta = with lib; { 143 description = "Python bindings for Mapnik"; 144 maintainers = with maintainers; [ ]; 145 homepage = "https://mapnik.org"; 146 license = licenses.lgpl21Plus; 147 }; 148}