From 189a229b6d4055eb50d9b61ccecff2e0fef68a4a Mon Sep 17 00:00:00 2001 From: Kerstin Humm Date: Sat, 13 Nov 2021 20:18:02 +0100 Subject: [PATCH] python3Packages.python-mapnik: unstable-2020-02-24 -> unstable-2020-09-08 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also: - use libxml2 for xml parsing - use newest boost - patch to find libmapnik{json,wkt}.a - fix license - add erictapen as maintainer - use same harfbuzz as mapnik - use pytestCheckHook, disable failing tests Co-Authored-by: Robert Schütz --- .../python-modules/python-mapnik/default.nix | 98 ++++++++++++++++--- .../python-mapnik/find-libmapnik.patch | 30 ++++++ pkgs/top-level/python-packages.nix | 11 ++- 3 files changed, 118 insertions(+), 21 deletions(-) create mode 100644 pkgs/development/python-modules/python-mapnik/find-libmapnik.patch diff --git a/pkgs/development/python-modules/python-mapnik/default.nix b/pkgs/development/python-modules/python-mapnik/default.nix index 2d888518ff45..3e7b70463245 100644 --- a/pkgs/development/python-modules/python-mapnik/default.nix +++ b/pkgs/development/python-modules/python-mapnik/default.nix @@ -1,6 +1,8 @@ { lib , buildPythonPackage , fetchFromGitHub +, fetchpatch +, substituteAll , isPyPy , python , pillow @@ -17,37 +19,45 @@ , mapnik , proj , zlib +, libxml2 +, sqlite +, nose +, pytestCheckHook }: buildPythonPackage rec { pname = "python-mapnik"; - version = "unstable-2020-02-24"; + version = "unstable-2020-09-08"; src = fetchFromGitHub { owner = "mapnik"; repo = "python-mapnik"; - rev = "7da019cf9eb12af8f8aa88b7d75789dfcd1e901b"; - sha256 = "0snn7q7w1ab90311q8wgd1z64kw1svm5w831q0xd6glqhah86qc8"; + rev = "a2c2a86eec954b42d7f00093da03807d0834b1b4"; + hash = "sha256-GwDdrutJOHtW7pIWiUAiu1xucmRvp7YFYB3YSCrDsrY="; + # Only needed for test data + fetchSubmodules = true; }; - disabled = isPyPy; - doCheck = false; # doesn't find needed test data files - preBuild = '' - export BOOST_PYTHON_LIB="boost_python${"${lib.versions.major python.version}${lib.versions.minor python.version}"}" - export BOOST_THREAD_LIB="boost_thread" - export BOOST_SYSTEM_LIB="boost_system" - export PYCAIRO=true - ''; + patches = [ + # https://github.com/mapnik/python-mapnik/issues/239 + (fetchpatch { + url = "https://github.com/koordinates/python-mapnik/commit/318b1edac16f48a7f21902c192c1dd86f6210a44.patch"; + sha256 = "sha256-cfU8ZqPPGCqoHEyGvJ8Xy/bGpbN2vSDct6A3N5+I8xM="; + }) + ./find-pycairo-with-pkg-config.patch + # python-mapnik seems to depend on having the mapnik src directory + # structure available at build time. We just hardcode the paths. + (substituteAll { + src = ./find-libmapnik.patch; + libmapnik = "${mapnik}/lib"; + }) + ]; nativeBuildInputs = [ mapnik # for mapnik_config pkg-config ]; - patches = [ - ./find-pycairo-with-pkg-config.patch - ]; - buildInputs = [ mapnik boost @@ -60,16 +70,72 @@ buildPythonPackage rec { libwebp proj zlib + libxml2 + sqlite ]; propagatedBuildInputs = [ pillow pycairo ]; + configureFlags = [ + "XMLPARSER=libxml2" + ]; + + disabled = isPyPy; + + preBuild = '' + export BOOST_PYTHON_LIB="boost_python${"${lib.versions.major python.version}${lib.versions.minor python.version}"}" + export BOOST_THREAD_LIB="boost_thread" + export BOOST_SYSTEM_LIB="boost_system" + export PYCAIRO=true + export XMLPARSER=libxml2 + ''; + + checkInputs = [ + nose + pytestCheckHook + ]; + + preCheck = '' + # import from $out + rm -r mapnik + ''; + + # https://github.com/mapnik/python-mapnik/issues/255 + disabledTests = [ + "test_adding_datasource_to_layer" + "test_compare_map" + "test_dataraster_coloring" + "test_dataraster_query_point" + "test_good_files" + "test_layer_init" + "test_load_save_map" + "test_loading_fontset_from_map" + "test_normalizing_definition" + "test_pdf_printing" + "test_proj_antimeridian_bbox" + "test_proj_transform_between_init_and_literal" + "test_pycairo_pdf_surface1" + "test_pycairo_svg_surface1" + "test_query_tolerance" + "test_raster_warping" + "test_raster_warping_does_not_overclip_source" + "test_render_points" + "test_render_with_scale_factor" + "test_style_level_image_filter" + "test_that_coordinates_do_not_overflow_and_polygon_is_rendered_csv" + "test_that_coordinates_do_not_overflow_and_polygon_is_rendered_memory" + "test_transparency_levels" + "test_visual_zoom_all_rendering1" + "test_visual_zoom_all_rendering2" + "test_wgs84_inverse_forward" + ]; + pythonImportsCheck = [ "mapnik" ]; meta = with lib; { description = "Python bindings for Mapnik"; maintainers = with maintainers; [ erictapen ]; homepage = "https://mapnik.org"; - license = licenses.lgpl21; + license = licenses.lgpl21Plus; }; } diff --git a/pkgs/development/python-modules/python-mapnik/find-libmapnik.patch b/pkgs/development/python-modules/python-mapnik/find-libmapnik.patch new file mode 100644 index 000000000000..cec557a2940a --- /dev/null +++ b/pkgs/development/python-modules/python-mapnik/find-libmapnik.patch @@ -0,0 +1,30 @@ +diff --git a/build.py b/build.py +index 0f94826b6..3cceb4546 100644 +--- a/build.py ++++ b/build.py +@@ -110,8 +110,8 @@ py_env.AppendUnique(LIBS='mapnik-wkt') + _mapnik = py_env.LoadableModule('mapnik/_mapnik', sources, LDMODULEPREFIX='', LDMODULESUFFIX='.so') + + Depends(_mapnik, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME'])) +-Depends(_mapnik, env.subst('../../src/json/libmapnik-json${LIBSUFFIX}')) +-Depends(_mapnik, env.subst('../../src/wkt/libmapnik-wkt${LIBSUFFIX}')) ++Depends(_mapnik, env.subst('@libmapnik@/libmapnikjson${LIBSUFFIX}')) ++Depends(_mapnik, env.subst('@libmapnik@/libmapnikwkt${LIBSUFFIX}')) + + if 'uninstall' not in COMMAND_LINE_TARGETS: + pymapniklib = env.Install(target_path,_mapnik) +diff --git a/setup.py b/setup.py +index 9985da5a2..5a03a1ec8 100755 +--- a/setup.py ++++ b/setup.py +@@ -118,8 +118,8 @@ linkflags.extend(check_output([mapnik_config, '--libs']).split(' ')) + linkflags.extend(check_output([mapnik_config, '--ldflags']).split(' ')) + linkflags.extend(check_output([mapnik_config, '--dep-libs']).split(' ')) + linkflags.extend([ +-'-lmapnik-wkt', +-'-lmapnik-json', ++'-lmapnikwkt', ++'-lmapnikjson', + ] + ['-l%s' % i for i in get_boost_library_names()]) + + # Dynamically make the mapnik/paths.py file diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 5f2c27456d33..6beb5e1c84f4 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -8998,16 +8998,17 @@ self: super: with self; { python-manilaclient = callPackage ../development/python-modules/python-manilaclient { }; - python-mapnik = let + python-mapnik = callPackage ../development/python-modules/python-mapnik rec { + inherit (pkgs) pkg-config cairo icu libjpeg libpng libtiff libwebp proj zlib; boost = pkgs.boost175.override { enablePython = true; inherit python; }; - in callPackage ../development/python-modules/python-mapnik { - inherit (pkgs) pkg-config cairo harfbuzz icu libjpeg libpng libtiff libwebp proj zlib; - inherit boost; + harfbuzz = pkgs.harfbuzz.override { + withIcu = true; + }; mapnik = pkgs.mapnik.override { - inherit boost; + inherit boost harfbuzz; }; };