Files
nixpkgs/pkgs/development/python-modules/python-mapnik/default.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

137 lines
2.9 KiB
Nix

{
lib,
buildPythonPackage,
fetchFromGitHub,
substituteAll,
isPyPy,
python,
setuptools,
pillow,
pycairo,
pkg-config,
boost,
cairo,
harfbuzz,
icu,
libjpeg,
libpng,
libtiff,
libwebp,
mapnik,
proj,
zlib,
libxml2,
sqlite,
pytestCheckHook,
darwin,
sparsehash,
}:
buildPythonPackage rec {
pname = "python-mapnik";
version = "3.0.16-unstable-2024-02-22";
pyproject = true;
src = fetchFromGitHub {
owner = "mapnik";
repo = "python-mapnik";
rev = "5ab32f0209909cc98c26e1d86ce0c8ef29a9bf3d";
hash = "sha256-OqijA1WcyBcyWO8gntqp+xNIaV1Jqa0n1eMDip2OCvY=";
# Only needed for test data
fetchSubmodules = true;
};
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";
})
# Use `std::optional` rather than `boost::optional`
# https://github.com/mapnik/python-mapnik/commit/e9f88a95a03dc081826a69da67bbec3e4cccd5eb
./python-mapnik_std_optional.patch
];
stdenv = if python.stdenv.hostPlatform.isDarwin then darwin.apple_sdk_11_0.stdenv else python.stdenv;
build-system = [ setuptools ];
nativeBuildInputs = [
mapnik # for mapnik_config
pkg-config
];
dependencies = [
mapnik
boost
cairo
harfbuzz
icu
libjpeg
libpng
libtiff
libwebp
proj
zlib
libxml2
sqlite
sparsehash
];
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
'';
nativeCheckInputs = [ pytestCheckHook ];
preCheck =
''
# import from $out
rm -r mapnik
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
# Replace the hardcoded /tmp references with $TMPDIR
sed -i "s,/tmp,$TMPDIR,g" test/python_tests/*.py
'';
# https://github.com/mapnik/python-mapnik/issues/255
disabledTests = [
"test_geometry_type"
"test_passing_pycairo_context_pdf"
"test_pdf_printing"
"test_render_with_scale_factor"
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
"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"
];
pythonImportsCheck = [ "mapnik" ];
meta = with lib; {
description = "Python bindings for Mapnik";
maintainers = [ ];
homepage = "https://mapnik.org";
license = licenses.lgpl21Plus;
};
}