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