summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/skia-pathops/default.nix
blob: 265fc0144153e489648dad59f6f62179b1636f45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{
  lib,
  stdenv,
  buildPythonPackage,
  cython,
  isPyPy,
  ninja,
  setuptools-scm,
  setuptools,
  fetchPypi,
  gn,
  pytestCheckHook,
  cctools,
  xcodebuild,
}:

buildPythonPackage rec {
  pname = "skia-pathops";
  version = "0.8.0.post2";
  pyproject = true;

  src = fetchPypi {
    pname = "skia_pathops";
    inherit version;
    extension = "zip";
    hash = "sha256-niUs3rbE0WLoKYbTHb2JxnXRZ3y4AZwuE+YpXUpVcmk=";
  };

  postPatch = ''
    substituteInPlace setup.py \
      --replace "build_cmd = [sys.executable, build_skia_py, build_dir]" \
        'build_cmd = [sys.executable, build_skia_py, "--no-fetch-gn", "--no-virtualenv", "--gn-path", "${gn}/bin/gn", build_dir]'
  ''
  + lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) ''
    substituteInPlace src/cpp/skia-builder/skia/gn/skia/BUILD.gn \
      --replace "-march=armv7-a" "-march=armv8-a" \
      --replace "-mfpu=neon" "" \
      --replace "-mthumb" ""
    substituteInPlace src/cpp/skia-builder/skia/src/core/SkOpts.cpp \
      --replace "defined(SK_CPU_ARM64)" "0"
  ''
  +
    lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) # old compiler?
      ''
        patch -p1 <<EOF
        --- a/src/cpp/skia-builder/skia/include/private/base/SkTArray.h
        +++ b/src/cpp/skia-builder/skia/include/private/base/SkTArray.h
        @@ -492 +492 @@:
        -    static constexpr int kMaxCapacity = SkToInt(std::min(SIZE_MAX / sizeof(T), (size_t)INT_MAX));
        +    static constexpr int kMaxCapacity = SkToInt(std::min<size_t>(SIZE_MAX / sizeof(T), (size_t)INT_MAX));
        EOF
      '';

  build-system = [
    cython
    setuptools
    setuptools-scm
  ];

  nativeBuildInputs = [
    ninja
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    cctools.libtool
    xcodebuild
  ];

  nativeCheckInputs = [ pytestCheckHook ];

  pythonImportsCheck = [ "pathops" ];

  meta = {
    description = "Python access to operations on paths using the Skia library";
    homepage = "https://github.com/fonttools/skia-pathops";
    license = lib.licenses.bsd3;
    maintainers = [ ];
    # "The Skia team is not endian-savvy enough to support big-endian CPUs."
    badPlatforms = lib.platforms.bigEndian;
    # ERROR at //gn/BUILDCONFIG.gn:87:14: Script returned non-zero exit code.
    broken = isPyPy;
  };
}