1{ lib
2, stdenv
3, buildPythonPackage
4, cython
5, isPyPy
6, ninja
7, setuptools-scm
8, setuptools
9, fetchPypi
10, gn
11, pytestCheckHook
12, xcodebuild
13, ApplicationServices
14, OpenGL
15}:
16
17buildPythonPackage rec {
18 pname = "skia-pathops";
19 version = "0.8.0.post1";
20
21 src = fetchPypi {
22 pname = "skia-pathops";
23 inherit version;
24 extension = "zip";
25 hash = "sha256-oFYkneL2H6VRFrnuVVE8aja4eK7gDJFFDkBNFgZIXLs=";
26 };
27
28 postPatch = ''
29 substituteInPlace setup.py \
30 --replace "build_cmd = [sys.executable, build_skia_py, build_dir]" \
31 'build_cmd = [sys.executable, build_skia_py, "--no-fetch-gn", "--no-virtualenv", "--gn-path", "${gn}/bin/gn", build_dir]'
32 '' + lib.optionalString (stdenv.isDarwin && stdenv.isAarch64) ''
33 substituteInPlace src/cpp/skia-builder/skia/gn/skia/BUILD.gn \
34 --replace "-march=armv7-a" "-march=armv8-a" \
35 --replace "-mfpu=neon" "" \
36 --replace "-mthumb" ""
37 substituteInPlace src/cpp/skia-builder/skia/src/core/SkOpts.cpp \
38 --replace "defined(SK_CPU_ARM64)" "0"
39 '' + lib.optionalString (stdenv.isDarwin && stdenv.isx86_64) /* old compiler? */ ''
40 patch -p1 <<EOF
41 --- a/src/cpp/skia-builder/skia/include/private/base/SkTArray.h
42 +++ b/src/cpp/skia-builder/skia/include/private/base/SkTArray.h
43 @@ -492 +492 @@:
44 - static constexpr int kMaxCapacity = SkToInt(std::min(SIZE_MAX / sizeof(T), (size_t)INT_MAX));
45 + static constexpr int kMaxCapacity = SkToInt(std::min<size_t>(SIZE_MAX / sizeof(T), (size_t)INT_MAX));
46 EOF
47 '';
48
49 nativeBuildInputs = [ cython ninja setuptools-scm ]
50 ++ lib.optionals stdenv.isDarwin [ xcodebuild ];
51
52 buildInputs = lib.optionals stdenv.isDarwin [ ApplicationServices OpenGL ];
53
54 propagatedBuildInputs = [ setuptools ];
55
56 nativeCheckInputs = [ pytestCheckHook ];
57
58 pythonImportsCheck = [ "pathops" ];
59
60 meta = {
61 description = "Python access to operations on paths using the Skia library";
62 homepage = "https://github.com/fonttools/skia-pathops";
63 license = lib.licenses.bsd3;
64 maintainers = [ lib.maintainers.BarinovMaxim ];
65 # ERROR at //gn/BUILDCONFIG.gn:87:14: Script returned non-zero exit code.
66 broken = isPyPy;
67 };
68}