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