1{ lib
2, stdenv
3, buildPythonPackage
4, pythonOlder
5, isPyPy
6, fetchFromGitHub
7, setuptools-scm
8, fs
9, lxml
10, brotli
11, brotlicffi
12, zopfli
13, unicodedata2
14, lz4
15, scipy
16, munkres
17, matplotlib
18, sympy
19, xattr
20, skia-pathops
21, uharfbuzz
22, pytestCheckHook
23}:
24
25buildPythonPackage rec {
26 pname = "fonttools";
27 version = "4.34.4";
28
29 disabled = pythonOlder "3.7";
30
31 src = fetchFromGitHub {
32 owner = pname;
33 repo = pname;
34 rev = "refs/tags/${version}";
35 sha256 = "sha256-GwbcrDsfxs5qRQJozhK/+n3W3NlO39g7pzxL9iIiDfU=";
36 };
37
38 nativeBuildInputs = [ setuptools-scm ];
39
40 passthru.optional-dependencies = let
41 extras = {
42 ufo = [ fs ];
43 lxml = [ lxml ];
44 woff = [ (if isPyPy then brotlicffi else brotli) zopfli ];
45 unicode = lib.optional (pythonOlder "3.11") unicodedata2;
46 graphite = [ lz4 ];
47 interpolatable = [ (if isPyPy then munkres else scipy) ];
48 plot = [ matplotlib ];
49 symfont = [ sympy ];
50 type1 = lib.optional stdenv.isDarwin xattr;
51 pathops = [ skia-pathops ];
52 repacker = [ uharfbuzz ];
53 };
54 in extras // {
55 all = lib.concatLists (lib.attrValues extras);
56 };
57
58 checkInputs = [
59 pytestCheckHook
60 ] ++ lib.concatLists (lib.attrVals ([
61 "woff"
62 "interpolatable"
63 ] ++ lib.optionals (!skia-pathops.meta.broken) [
64 "pathops" # broken
65 ] ++ [
66 "repacker"
67 ]) passthru.optional-dependencies);
68
69 pythonImportsCheck = [ "fontTools" ];
70
71 preCheck = ''
72 # tests want to execute the "fonttools" executable from $PATH
73 export PATH="$out/bin:$PATH"
74 '';
75
76 # Timestamp tests have timing issues probably related
77 # to our file timestamp normalization
78 disabledTests = [
79 "test_recalc_timestamp_ttf"
80 "test_recalc_timestamp_otf"
81 "test_ttcompile_timestamp_calcs"
82 ];
83
84 disabledTestPaths = [
85 # avoid test which depend on fs and matplotlib
86 # fs and matplotlib were removed to prevent strong cyclic dependencies
87 "Tests/misc/plistlib_test.py"
88 "Tests/pens"
89 "Tests/ufoLib"
90 ];
91
92 meta = with lib; {
93 homepage = "https://github.com/fonttools/fonttools";
94 description = "A library to manipulate font files from Python";
95 license = licenses.mit;
96 maintainers = [ maintainers.sternenseemann ];
97 };
98}