1{
2 lib,
3 stdenv,
4 python,
5 buildPythonPackage,
6 pythonOlder,
7 fetchPypi,
8 flit-core,
9 babel,
10 markupsafe,
11 pytestCheckHook,
12 sphinxHook,
13 pallets-sphinx-themes,
14 sphinxcontrib-log-cabinet,
15 sphinx-issues,
16
17 # Reverse dependency
18 sage,
19}:
20
21buildPythonPackage rec {
22 pname = "jinja2";
23 version = "3.1.6";
24 pyproject = true;
25
26 disabled = pythonOlder "3.7";
27
28 src = fetchPypi {
29 inherit pname version;
30 hash = "sha256-ATf7BZkNNfEnWlh+mu5tVtqCH8g0kaD7g4GDvkP2bW0=";
31 };
32
33 postPatch = ''
34 # Do not test with trio, it increases jinja2's dependency closure by a lot
35 # and everyone consuming these dependencies cannot rely on sphinxHook,
36 # because sphinx itself depends on jinja2.
37 substituteInPlace tests/test_async{,_filters}.py \
38 --replace-fail "import trio" "" \
39 --replace-fail ", trio.run" "" \
40 --replace-fail ", \"trio\"" ""
41 '';
42
43 build-system = [ flit-core ];
44
45 dependencies = [ markupsafe ];
46
47 optional-dependencies = {
48 i18n = [ babel ];
49 };
50
51 # Multiple tests run out of stack space on 32bit systems with python2.
52 # See https://github.com/pallets/jinja/issues/1158
53 doCheck = !stdenv.hostPlatform.is32bit;
54
55 nativeCheckInputs = [ pytestCheckHook ] ++ optional-dependencies.i18n;
56
57 passthru.doc = stdenv.mkDerivation {
58 # Forge look and feel of multi-output derivation as best as we can.
59 #
60 # Using 'outputs = [ "doc" ];' breaks a lot of assumptions.
61 name = "${pname}-${version}-doc";
62 inherit src pname version;
63
64 patches = [
65 # Fix import of "sphinxcontrib-log-cabinet"
66 ./patches/import-order.patch
67 ];
68
69 postInstallSphinx = ''
70 mv $out/share/doc/* $out/share/doc/python$pythonVersion-$pname-$version
71 '';
72
73 nativeBuildInputs = [
74 sphinxHook
75 sphinxcontrib-log-cabinet
76 pallets-sphinx-themes
77 sphinx-issues
78 ];
79
80 inherit (python) pythonVersion;
81 inherit meta;
82 };
83
84 passthru.tests = {
85 inherit sage;
86 };
87
88 meta = with lib; {
89 changelog = "https://github.com/pallets/jinja/blob/${version}/CHANGES.rst";
90 description = "Very fast and expressive template engine";
91 downloadPage = "https://github.com/pallets/jinja";
92 homepage = "https://jinja.palletsprojects.com";
93 license = licenses.bsd3;
94 longDescription = ''
95 Jinja is a fast, expressive, extensible templating engine. Special
96 placeholders in the template allow writing code similar to Python
97 syntax. Then the template is passed data to render the final document.
98 '';
99 maintainers = with maintainers; [ pierron ];
100 };
101}