about summary refs log tree commit diff
path: root/pkgs/development/python-modules/gftools/default.nix
blob: 2aec534c5353badefba7f75a4b64c73b195fd5d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
{
  lib,
  fetchFromGitHub,
  buildPythonPackage,
  pytestCheckHook,
  setuptools,
  setuptools-scm,
  absl-py,
  afdko,
  axisregistry,
  babelfont,
  beautifulsoup4,
  black,
  brotli,
  bumpfontversion,
  coreutils,
  diffenator2,
  font-v,
  fontbakery,
  fontfeatures,
  fontmake,
  fonttools,
  gflanguages,
  gfsubsets,
  glyphsets,
  glyphslib,
  harfbuzz,
  jinja2,
  nanoemoji,
  networkx,
  ninja,
  opentype-feature-freezer,
  ots-python,
  packaging,
  paintcompiler,
  pillow,
  protobuf,
  pycairo,
  pygit2,
  pygithub,
  pytest,
  pyyaml,
  requests,
  rich,
  ruamel-yaml,
  skia-pathops,
  statmake,
  strictyaml,
  tabulate,
  ttfautohint-py,
  ufomerge,
  unidecode,
  vharfbuzz,
  vttlib,
  python,
}:

let
  fontmake' = python.withPackages (ps: [ ps.fontmake ] ++ ps.fontmake.optional-dependencies.json);
  fonttools' = python.withPackages (ps: [ ps.fonttools ] ++ ps.fonttools.optional-dependencies.ufo);
in
buildPythonPackage rec {
  pname = "gftools";
  version = "0.9.70";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "googlefonts";
    repo = "gftools";
    rev = "refs/tags/v${version}";
    hash = "sha256-mZGkcIODzc2nuhAWU83BkhjWg4+8vnmCA4eXgDsyFy8=";
  };

  postPatch = ''
    substituteInPlace \
      Lib/gftools/builder/operations/{buildTTF,glyphs2ds,buildVariable,buildOTF}.py \
      --replace-fail '"fontmake' '"${lib.getExe' fontmake' "fontmake"}'

    substituteInPlace \
      Lib/gftools/builder/operations/instantiateUfo.py \
      --replace-fail "'fontmake" "'${lib.getExe' fontmake' "fontmake"}"

    substituteInPlace \
      Lib/gftools/builder/operations/{compress,subspace}.py \
      --replace-fail '"fonttools' '"${lib.getExe' fonttools' "fonttools"}'

    substituteInPlace \
      Lib/gftools/builder/operations/hbsubset.py \
      --replace-fail '"pyftsubset"' '"${lib.getExe' fonttools' "pyftsubset"}"' \
      --replace-fail '"hb-subset"' '"${lib.getExe' harfbuzz "hb-subset"}"'

    substituteInPlace \
      Lib/gftools/builder/operations/autohintOTF.py \
      --replace-fail '"otfautohint' '"${lib.getExe' afdko "otfautohint"}'

    substituteInPlace \
      Lib/gftools/builder/operations/paintcompiler.py \
      --replace-fail '"paintcompiler' '"${lib.getExe paintcompiler}'

    substituteInPlace \
      Lib/gftools/builder/operations/featureFreeze.py \
      --replace-fail '"pyftfeatfreeze' '"${lib.getExe opentype-feature-freezer}'

    substituteInPlace \
      Lib/gftools/builder/operations/copy.py \
      --replace-fail '"cp' '"${lib.getExe' coreutils "cp"}'

    substituteInPlace \
      Lib/gftools/builder/operations/{fix,remap,autohint,buildStat,addSubset,remapLayout,buildVTT}.py \
      --replace-fail '"gftools' '"${placeholder "out"}/bin/gftools'

    substituteInPlace \
      Lib/gftools/builder/operations/rename.py \
      --replace-fail "'gftools" "'${placeholder "out"}t/bin/gftools"
  '';

  pythonRelaxDeps = [
    "protobuf"
    "pygit2"
  ];

  build-system = [
    setuptools
    setuptools-scm
  ];

  dependencies = [
    absl-py
    afdko
    axisregistry
    babelfont
    beautifulsoup4
    brotli
    bumpfontversion
    font-v
    fontfeatures
    fontmake
    fonttools
    gflanguages
    gfsubsets
    glyphsets
    glyphslib
    jinja2
    nanoemoji
    networkx
    ninja
    ots-python
    packaging
    pillow
    protobuf
    pygit2
    pygithub
    pyyaml
    requests
    rich
    ruamel-yaml
    setuptools
    skia-pathops
    statmake
    strictyaml
    tabulate
    ttfautohint-py
    ufomerge
    unidecode
    vharfbuzz
    vttlib
  ] ++ fonttools.optional-dependencies.ufo ++ fontmake.optional-dependencies.json;

  optional-dependencies = {
    qa = [
      diffenator2
      fontbakery
      pycairo
    ];
    test = [
      black
      pytest
    ];
  };

  nativeCheckInputs = [ pytestCheckHook ];

  disabledTestPaths = [
    # Wants none exsiting module
    "bin/test_args.py"
    # Requires internet
    "tests/push/test_items.py"
    "tests/test_gfgithub.py"
    "tests/test_usage.py"
    "tests/push/test_servers.py"
    # Can't find directory
    "tests/test_builder.py"
    "tests/test_dependencies.py"
    "tests/test_fix.py"
  ];

  pythonImportsCheck = [ "gftools" ];

  meta = with lib; {
    description = "Misc tools for working with the Google Fonts library";
    homepage = "https://github.com/googlefonts/gftools";
    changelog = "https://github.com/googlefonts/gftools/releases/tag/v${version}";
    license = licenses.asl20;
    mainProgram = "gftools";
    maintainers = with maintainers; [ jopejoe1 ];
  };
}