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