2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
buildPythonPackage,
|
|
|
|
fetchFromGitHub,
|
|
|
|
substituteAll,
|
|
|
|
isPyPy,
|
|
|
|
python,
|
2024-07-31 10:19:44 +00:00
|
|
|
setuptools,
|
2024-06-05 15:53:02 +00:00
|
|
|
pillow,
|
|
|
|
pycairo,
|
|
|
|
pkg-config,
|
|
|
|
boost,
|
|
|
|
cairo,
|
|
|
|
harfbuzz,
|
|
|
|
icu,
|
|
|
|
libjpeg,
|
|
|
|
libpng,
|
|
|
|
libtiff,
|
|
|
|
libwebp,
|
|
|
|
mapnik,
|
|
|
|
proj,
|
|
|
|
zlib,
|
|
|
|
libxml2,
|
|
|
|
sqlite,
|
|
|
|
pytestCheckHook,
|
2024-06-20 14:57:18 +00:00
|
|
|
darwin,
|
|
|
|
sparsehash,
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2021-08-05 21:33:18 +00:00
|
|
|
buildPythonPackage rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "python-mapnik";
|
2024-06-20 14:57:18 +00:00
|
|
|
version = "3.0.16-unstable-2024-02-22";
|
2024-07-31 10:19:44 +00:00
|
|
|
pyproject = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-08-05 21:33:18 +00:00
|
|
|
src = fetchFromGitHub {
|
2020-04-24 23:36:52 +00:00
|
|
|
owner = "mapnik";
|
|
|
|
repo = "python-mapnik";
|
2024-06-20 14:57:18 +00:00
|
|
|
rev = "5ab32f0209909cc98c26e1d86ce0c8ef29a9bf3d";
|
|
|
|
hash = "sha256-OqijA1WcyBcyWO8gntqp+xNIaV1Jqa0n1eMDip2OCvY=";
|
2022-11-21 17:40:18 +00:00
|
|
|
# Only needed for test data
|
|
|
|
fetchSubmodules = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
patches = [
|
|
|
|
# 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";
|
|
|
|
})
|
2024-06-20 14:57:18 +00:00
|
|
|
# Use `std::optional` rather than `boost::optional`
|
|
|
|
# https://github.com/mapnik/python-mapnik/commit/e9f88a95a03dc081826a69da67bbec3e4cccd5eb
|
|
|
|
./python-mapnik_std_optional.patch
|
2022-11-21 17:40:18 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-09-26 11:04:55 +00:00
|
|
|
stdenv = if python.stdenv.hostPlatform.isDarwin then darwin.apple_sdk_11_0.stdenv else python.stdenv;
|
2024-06-20 14:57:18 +00:00
|
|
|
|
2024-07-31 10:19:44 +00:00
|
|
|
build-system = [ setuptools ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
mapnik # for mapnik_config
|
2021-08-05 21:33:18 +00:00
|
|
|
pkg-config
|
2021-05-20 23:08:51 +00:00
|
|
|
];
|
|
|
|
|
2024-07-31 10:19:44 +00:00
|
|
|
dependencies = [
|
2020-04-24 23:36:52 +00:00
|
|
|
mapnik
|
2024-01-13 08:15:51 +00:00
|
|
|
boost
|
2020-04-24 23:36:52 +00:00
|
|
|
cairo
|
|
|
|
harfbuzz
|
|
|
|
icu
|
|
|
|
libjpeg
|
|
|
|
libpng
|
|
|
|
libtiff
|
|
|
|
libwebp
|
|
|
|
proj
|
|
|
|
zlib
|
2022-11-21 17:40:18 +00:00
|
|
|
libxml2
|
|
|
|
sqlite
|
2024-06-20 14:57:18 +00:00
|
|
|
sparsehash
|
2021-08-05 21:33:18 +00:00
|
|
|
];
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
pillow
|
|
|
|
pycairo
|
2022-11-21 17:40:18 +00:00
|
|
|
];
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
configureFlags = [ "XMLPARSER=libxml2" ];
|
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
2024-07-31 10:19:44 +00:00
|
|
|
nativeCheckInputs = [ pytestCheckHook ];
|
2022-11-21 17:40:18 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
preCheck =
|
|
|
|
''
|
|
|
|
# import from $out
|
|
|
|
rm -r mapnik
|
|
|
|
''
|
2024-09-26 11:04:55 +00:00
|
|
|
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
|
2024-06-05 15:53:02 +00:00
|
|
|
# Replace the hardcoded /tmp references with $TMPDIR
|
|
|
|
sed -i "s,/tmp,$TMPDIR,g" test/python_tests/*.py
|
|
|
|
'';
|
2022-11-21 17:40:18 +00:00
|
|
|
|
|
|
|
# https://github.com/mapnik/python-mapnik/issues/255
|
|
|
|
disabledTests = [
|
2023-05-24 13:37:59 +00:00
|
|
|
"test_geometry_type"
|
2024-01-13 08:15:51 +00:00
|
|
|
"test_passing_pycairo_context_pdf"
|
2022-11-21 17:40:18 +00:00
|
|
|
"test_pdf_printing"
|
2024-06-20 14:57:18 +00:00
|
|
|
"test_render_with_scale_factor"
|
2024-09-26 11:04:55 +00:00
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
|
2024-06-20 14:57:18 +00:00
|
|
|
"test_passing_pycairo_context_png"
|
|
|
|
"test_passing_pycairo_context_svg"
|
|
|
|
"test_pycairo_pdf_surface1"
|
|
|
|
"test_pycairo_pdf_surface2"
|
|
|
|
"test_pycairo_pdf_surface3"
|
|
|
|
"test_pycairo_svg_surface1"
|
|
|
|
"test_pycairo_svg_surface2"
|
|
|
|
"test_pycairo_svg_surface3"
|
|
|
|
];
|
2022-11-21 17:40:18 +00:00
|
|
|
|
2021-08-05 21:33:18 +00:00
|
|
|
pythonImportsCheck = [ "mapnik" ];
|
2021-05-29 03:34:57 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Python bindings for Mapnik";
|
2024-07-31 10:19:44 +00:00
|
|
|
maintainers = [ ];
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://mapnik.org";
|
2022-11-21 17:40:18 +00:00
|
|
|
license = licenses.lgpl21Plus;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|