nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 pythonOlder,
6 isPyPy,
7 fetchFromGitHub,
8 setuptools,
9 setuptools-scm,
10 lxml,
11 brotli,
12 brotlicffi,
13 zopfli,
14 unicodedata2,
15 lz4,
16 scipy,
17 munkres,
18 pycairo,
19 matplotlib,
20 sympy,
21 xattr,
22 skia-pathops,
23 uharfbuzz,
24 pytestCheckHook,
25}:
26
27buildPythonPackage rec {
28 pname = "fonttools";
29 version = "4.61.1";
30 pyproject = true;
31
32 src = fetchFromGitHub {
33 owner = "fonttools";
34 repo = "fonttools";
35 tag = version;
36 hash = "sha256-762bqAhOqqnuNSH8yFLTBnzYuigs716nt+uC1UwUqT4=";
37 };
38
39 build-system = [
40 setuptools
41 setuptools-scm
42 ];
43
44 optional-dependencies =
45 let
46 extras = {
47 ufo = [ ];
48 lxml = [ lxml ];
49 woff = [
50 (if isPyPy then brotlicffi else brotli)
51 zopfli
52 ];
53 unicode = lib.optional (pythonOlder "3.13") unicodedata2;
54 graphite = [ lz4 ];
55 interpolatable = [
56 pycairo
57 (if isPyPy then munkres else scipy)
58 ];
59 plot = [ matplotlib ];
60 symfont = [ sympy ];
61 type1 = lib.optional stdenv.hostPlatform.isDarwin xattr;
62 pathops = lib.optional (lib.meta.availableOn stdenv.hostPlatform skia-pathops) skia-pathops;
63 repacker = [ uharfbuzz ];
64 };
65 in
66 extras // { all = lib.concatLists (lib.attrValues extras); };
67
68 nativeCheckInputs = [
69 pytestCheckHook
70 ]
71 ++ lib.concatLists (
72 lib.attrVals (
73 [
74 "woff"
75 # "interpolatable" is not included because it only contains 2 tests at the time of writing but adds 270 extra dependencies
76 "ufo"
77 ]
78 ++ lib.optionals (!skia-pathops.meta.broken) [
79 "pathops" # broken
80 ]
81 ++ [ "repacker" ]
82 ) optional-dependencies
83 );
84
85 pythonImportsCheck = [ "fontTools" ];
86
87 preCheck = ''
88 # tests want to execute the "fonttools" executable from $PATH
89 export PATH="$out/bin:$PATH"
90 '';
91
92 # Timestamp tests have timing issues probably related
93 # to our file timestamp normalization
94 disabledTests = [
95 "test_recalc_timestamp_ttf"
96 "test_recalc_timestamp_otf"
97 "test_ttcompile_timestamp_calcs"
98 ];
99
100 meta = {
101 homepage = "https://github.com/fonttools/fonttools";
102 description = "Library to manipulate font files from Python";
103 changelog = "https://github.com/fonttools/fonttools/blob/${src.tag}/NEWS.rst";
104 license = lib.licenses.mit;
105 maintainers = [ lib.maintainers.sternenseemann ];
106 };
107}