1{
2 lib,
3 fetchFromGitHub,
4 buildPythonPackage,
5 pytestCheckHook,
6 setuptools,
7 setuptools-scm,
8 absl-py,
9 afdko,
10 axisregistry,
11 babelfont,
12 beautifulsoup4,
13 black,
14 brotli,
15 bumpfontversion,
16 coreutils,
17 diffenator2,
18 font-v,
19 fontbakery,
20 fontfeatures,
21 fontmake,
22 fonttools,
23 gflanguages,
24 gfsubsets,
25 glyphsets,
26 glyphslib,
27 harfbuzz,
28 jinja2,
29 nanoemoji,
30 networkx,
31 ninja,
32 opentype-feature-freezer,
33 ots-python,
34 packaging,
35 paintcompiler,
36 pillow,
37 protobuf,
38 pycairo,
39 pygit2,
40 pygithub,
41 pytest,
42 pyyaml,
43 requests,
44 rich,
45 ruamel-yaml,
46 skia-pathops,
47 statmake,
48 strictyaml,
49 tabulate,
50 ttfautohint-py,
51 ufomerge,
52 unidecode,
53 vharfbuzz,
54 vttlib,
55 python,
56}:
57
58let
59 fontmake' = python.withPackages (ps: [ ps.fontmake ] ++ ps.fontmake.optional-dependencies.json);
60 fonttools' = python.withPackages (ps: [ ps.fonttools ] ++ ps.fonttools.optional-dependencies.ufo);
61in
62buildPythonPackage rec {
63 pname = "gftools";
64 version = "0.9.81";
65 pyproject = true;
66
67 src = fetchFromGitHub {
68 owner = "googlefonts";
69 repo = "gftools";
70 tag = "v${version}";
71 hash = "sha256-+9M3PM9LM1/nqNstdAVlF/sF2Xl/xeZN3L8RvjywEIU=";
72 };
73
74 postPatch = ''
75 substituteInPlace \
76 Lib/gftools/builder/operations/{buildTTF,glyphs2ds,buildVariable,buildOTF}.py \
77 --replace-fail '"fontmake' '"${lib.getExe' fontmake' "fontmake"}'
78
79 substituteInPlace \
80 Lib/gftools/builder/operations/instantiateUfo.py \
81 --replace-fail "'fontmake" "'${lib.getExe' fontmake' "fontmake"}"
82
83 substituteInPlace \
84 Lib/gftools/builder/operations/{compress,subspace}.py \
85 --replace-fail '"fonttools' '"${lib.getExe' fonttools' "fonttools"}'
86
87 substituteInPlace \
88 Lib/gftools/builder/operations/hbsubset.py \
89 --replace-fail '"pyftsubset"' '"${lib.getExe' fonttools' "pyftsubset"}"' \
90 --replace-fail '"hb-subset"' '"${lib.getExe' harfbuzz "hb-subset"}"'
91
92 substituteInPlace \
93 Lib/gftools/builder/operations/autohintOTF.py \
94 --replace-fail '"otfautohint' '"${lib.getExe' afdko "otfautohint"}'
95
96 substituteInPlace \
97 Lib/gftools/builder/operations/paintcompiler.py \
98 --replace-fail '"paintcompiler' '"${lib.getExe paintcompiler}'
99
100 substituteInPlace \
101 Lib/gftools/builder/operations/featureFreeze.py \
102 --replace-fail '"pyftfeatfreeze' '"${lib.getExe opentype-feature-freezer}'
103
104 substituteInPlace \
105 Lib/gftools/builder/operations/copy.py \
106 --replace-fail '"cp' '"${lib.getExe' coreutils "cp"}'
107
108 substituteInPlace \
109 Lib/gftools/builder/operations/{fix,remap,autohint,buildStat,addSubset,remapLayout,buildVTT}.py \
110 --replace-fail '"gftools' '"${placeholder "out"}/bin/gftools'
111
112 substituteInPlace \
113 Lib/gftools/builder/operations/rename.py \
114 --replace-fail "'gftools" "'${placeholder "out"}t/bin/gftools"
115 '';
116
117 env.PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION = "python";
118
119 pythonRelaxDeps = [
120 "protobuf"
121 "pygit2"
122 ];
123
124 build-system = [
125 setuptools
126 setuptools-scm
127 ];
128
129 dependencies =
130 [
131 absl-py
132 afdko
133 axisregistry
134 babelfont
135 beautifulsoup4
136 brotli
137 bumpfontversion
138 font-v
139 fontfeatures
140 fontmake
141 fonttools
142 gflanguages
143 gfsubsets
144 glyphsets
145 glyphslib
146 jinja2
147 nanoemoji
148 networkx
149 ninja
150 ots-python
151 packaging
152 pillow
153 protobuf
154 pygit2
155 pygithub
156 pyyaml
157 requests
158 rich
159 ruamel-yaml
160 setuptools
161 skia-pathops
162 statmake
163 strictyaml
164 tabulate
165 ttfautohint-py
166 ufomerge
167 unidecode
168 vharfbuzz
169 vttlib
170 ]
171 ++ fonttools.optional-dependencies.ufo
172 ++ fontmake.optional-dependencies.json;
173
174 optional-dependencies = {
175 qa = [
176 diffenator2
177 fontbakery
178 pycairo
179 ];
180 test = [
181 black
182 pytest
183 ];
184 };
185
186 nativeCheckInputs = [ pytestCheckHook ];
187
188 disabledTestPaths = [
189 # Wants none existing module
190 "bin/test_args.py"
191 # Requires internet
192 "tests/push/test_items.py"
193 "tests/test_gfgithub.py"
194 "tests/test_usage.py"
195 "tests/push/test_servers.py"
196 # Can't find directory
197 "tests/test_builder.py"
198 "tests/test_dependencies.py"
199 "tests/test_fix.py"
200 ];
201
202 pythonImportsCheck = [ "gftools" ];
203
204 meta = with lib; {
205 description = "Misc tools for working with the Google Fonts library";
206 homepage = "https://github.com/googlefonts/gftools";
207 changelog = "https://github.com/googlefonts/gftools/releases/tag/${src.tag}";
208 license = licenses.asl20;
209 mainProgram = "gftools";
210 maintainers = with maintainers; [ jopejoe1 ];
211 };
212}