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