1{
2 buildPythonPackage,
3 cython,
4 fetchPypi,
5 fetchpatch,
6 fontconfig,
7 freefont_ttf,
8 lib,
9 makeFontsConf,
10 python,
11}:
12
13let
14 fontsConf = makeFontsConf { fontDirectories = [ freefont_ttf ]; };
15in
16buildPythonPackage rec {
17 pname = "python-fontconfig";
18 version = "0.5.1";
19
20 src = fetchPypi {
21 pname = "Python-fontconfig";
22 inherit version;
23 sha256 = "154rfd0ygcbj9y8m32n537b457yijpfx9dvmf76vi0rg4ikf7kxp";
24 };
25
26 buildInputs = [ fontconfig ];
27 nativeBuildInputs = [ cython ];
28
29 patches = [
30 # distutils has been removed since python 3.12
31 # See https://github.com/vayn/python-fontconfig/pull/10
32 (fetchpatch {
33 name = "no-distutils.patch";
34 url = "https://github.com/vayn/python-fontconfig/commit/15e1a72c90e93a665569e0ba771ae53c7c8020c8.patch";
35 hash = "sha256-2mAemltWh3+LV4FDOg6uSD09zok3Eyd+v1WJJdouOV8=";
36 })
37 ];
38
39 preBuild = ''
40 ${python.pythonOnBuildForHost.interpreter} setup.py build_ext -i
41 '';
42
43 checkPhase = ''
44 export FONTCONFIG_FILE=${fontsConf};
45 echo y | ${python.interpreter} test/test.py
46 '';
47
48 meta = {
49 homepage = "https://github.com/Vayn/python-fontconfig";
50 description = "Python binding for Fontconfig";
51 license = lib.licenses.gpl3;
52 maintainers = [ ];
53 };
54}