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