nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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.9.1";
20 pyproject = true;
21
22 src = fetchPypi {
23 pname = "skia_pathops";
24 inherit version;
25 hash = "sha256-8Sc+9NojVw8z5253U5CEhOWkokaPexCJ+REMzuYpP5k=";
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 ''
33 + lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) ''
34 substituteInPlace src/cpp/skia-builder/skia/gn/skia/BUILD.gn \
35 --replace "-march=armv7-a" "-march=armv8-a" \
36 --replace "-mfpu=neon" "" \
37 --replace "-mthumb" ""
38 substituteInPlace src/cpp/skia-builder/skia/src/core/SkOpts.cpp \
39 --replace "defined(SK_CPU_ARM64)" "0"
40 ''
41 +
42 lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) # old compiler?
43 ''
44 patch -p1 <<EOF
45 --- a/src/cpp/skia-builder/skia/include/private/base/SkTArray.h
46 +++ b/src/cpp/skia-builder/skia/include/private/base/SkTArray.h
47 @@ -492 +492 @@:
48 - static constexpr int kMaxCapacity = SkToInt(std::min(SIZE_MAX / sizeof(T), (size_t)INT_MAX));
49 + static constexpr int kMaxCapacity = SkToInt(std::min<size_t>(SIZE_MAX / sizeof(T), (size_t)INT_MAX));
50 EOF
51 '';
52
53 build-system = [
54 cython
55 setuptools
56 setuptools-scm
57 ];
58
59 nativeBuildInputs = [
60 ninja
61 ]
62 ++ lib.optionals stdenv.hostPlatform.isDarwin [
63 cctools.libtool
64 xcodebuild
65 ];
66
67 nativeCheckInputs = [ pytestCheckHook ];
68
69 pythonImportsCheck = [ "pathops" ];
70
71 meta = {
72 description = "Python access to operations on paths using the Skia library";
73 homepage = "https://github.com/fonttools/skia-pathops";
74 license = lib.licenses.bsd3;
75 maintainers = [ ];
76 # "The Skia team is not endian-savvy enough to support big-endian CPUs."
77 badPlatforms = lib.platforms.bigEndian;
78 # ERROR at //gn/BUILDCONFIG.gn:87:14: Script returned non-zero exit code.
79 broken = isPyPy;
80 };
81}