1{ lib
2, stdenv
3, buildPythonPackage
4, fetchPypi
5, fetchpatch
6, pythonOlder
7, fonttools
8, defcon
9, lxml
10, fs
11, unicodedata2
12, zopfli
13, brotlipy
14, fontpens
15, brotli
16, fontmath
17, mutatormath
18, booleanoperations
19, ufoprocessor
20, ufonormalizer
21, psautohint
22, tqdm
23, setuptools-scm
24, scikit-build
25, cmake
26, antlr4_9
27, libxml2
28, pytestCheckHook
29# Enables some expensive tests, useful for verifying an update
30, runAllTests ? false
31, afdko
32}:
33
34buildPythonPackage rec {
35 pname = "afdko";
36 version = "3.9.3";
37 format = "pyproject";
38
39 disabled = pythonOlder "3.7";
40
41 src = fetchPypi {
42 inherit pname version;
43 hash = "sha256-v0fIhf3P5Xjdn5/ryRNj0Q2YHAisMqi5RTmJQabaUO0=";
44 };
45
46 nativeBuildInputs = [
47 setuptools-scm
48 scikit-build
49 cmake
50 ];
51
52 buildInputs = [
53 antlr4_9.runtime.cpp
54 libxml2.dev
55 ];
56
57 patches = [
58 # Don't try to install cmake and ninja using pip
59 ./no-pypi-build-tools.patch
60
61 # Use antlr4 runtime from nixpkgs and link it dynamically
62 ./use-dynamic-system-antlr4-runtime.patch
63 ];
64
65 # setup.py will always (re-)execute cmake in buildPhase
66 dontConfigure = true;
67
68 propagatedBuildInputs = [
69 booleanoperations
70 fonttools
71 lxml # fonttools[lxml], defcon[lxml] extra
72 fs # fonttools[ufo] extra
73 unicodedata2 # fonttools[unicode] extra
74 brotlipy # fonttools[woff] extra
75 zopfli # fonttools[woff] extra
76 fontpens
77 brotli
78 defcon
79 fontmath
80 mutatormath
81 ufoprocessor
82 ufonormalizer
83 psautohint
84 tqdm
85 ];
86
87 # Use system libxml2
88 FORCE_SYSTEM_LIBXML2 = true;
89
90 nativeCheckInputs = [ pytestCheckHook ];
91
92 preCheck = ''
93 export PATH=$PATH:$out/bin
94 '';
95
96 disabledTests = lib.optionals (!runAllTests) [
97 # Disable slow tests, reduces test time ~25 %
98 "test_report"
99 "test_post_overflow"
100 "test_cjk"
101 "test_extrapolate"
102 "test_filename_without_dir"
103 "test_overwrite"
104 "test_options"
105 ] ++ lib.optionals (stdenv.hostPlatform.isAarch || stdenv.hostPlatform.isRiscV) [
106 # unknown reason so far
107 # https://github.com/adobe-type-tools/afdko/issues/1425
108 "test_spec"
109 ] ++ lib.optionals (stdenv.hostPlatform.isi686) [
110 "test_dump_option"
111 "test_type1mm_inputs"
112 ];
113
114 passthru.tests = {
115 fullTestsuite = afdko.override { runAllTests = true; };
116 };
117
118 meta = with lib; {
119 changelog = "https://github.com/adobe-type-tools/afdko/blob/${version}/NEWS.md";
120 description = "Adobe Font Development Kit for OpenType";
121 homepage = "https://adobe-type-tools.github.io/afdko";
122 license = licenses.asl20;
123 maintainers = [ maintainers.sternenseemann ];
124 };
125}