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.4";
24 pyproject = true;
25
26 disabled = pythonOlder "3.7";
27
28 src = fetchPypi {
29 inherit pname version;
30 hash = "sha256-Sjruesu+cwOu3o6WSNE7i/iKQpKCqmEiqZPwrIAMs2k=";
31 };
32
33 nativeBuildInputs = [ flit-core ];
34
35 propagatedBuildInputs = [ markupsafe ];
36
37 passthru.optional-dependencies = {
38 i18n = [ babel ];
39 };
40
41 # Multiple tests run out of stack space on 32bit systems with python2.
42 # See https://github.com/pallets/jinja/issues/1158
43 doCheck = !stdenv.is32bit;
44
45 nativeCheckInputs = [ pytestCheckHook ] ++ passthru.optional-dependencies.i18n;
46
47 passthru.doc = stdenv.mkDerivation {
48 # Forge look and feel of multi-output derivation as best as we can.
49 #
50 # Using 'outputs = [ "doc" ];' breaks a lot of assumptions.
51 name = "${pname}-${version}-doc";
52 inherit src pname version;
53
54 patches = [
55 # Fix import of "sphinxcontrib-log-cabinet"
56 ./patches/import-order.patch
57 ];
58
59 postInstallSphinx = ''
60 mv $out/share/doc/* $out/share/doc/python$pythonVersion-$pname-$version
61 '';
62
63 nativeBuildInputs = [
64 sphinxHook
65 sphinxcontrib-log-cabinet
66 pallets-sphinx-themes
67 sphinx-issues
68 ];
69
70 inherit (python) pythonVersion;
71 inherit meta;
72 };
73
74 passthru.tests = {
75 inherit sage;
76 };
77
78 meta = with lib; {
79 changelog = "https://github.com/pallets/jinja/blob/${version}/CHANGES.rst";
80 description = "Very fast and expressive template engine";
81 downloadPage = "https://github.com/pallets/jinja";
82 homepage = "https://jinja.palletsprojects.com";
83 license = licenses.bsd3;
84 longDescription = ''
85 Jinja is a fast, expressive, extensible templating engine. Special
86 placeholders in the template allow writing code similar to Python
87 syntax. Then the template is passed data to render the final document.
88 '';
89 maintainers = with maintainers; [ pierron ];
90 };
91}