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