1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pythonOlder,
6
7 # build-system
8 poetry-core,
9
10 # dependencies
11 markdown-it-py,
12 pygments,
13 typing-extensions,
14
15 # optional-dependencies
16 ipywidgets,
17
18 # tests
19 attrs,
20 pytestCheckHook,
21 setuptools,
22
23 # for passthru.tests
24 enrich,
25 httpie,
26 rich-rst,
27 textual,
28}:
29
30buildPythonPackage rec {
31 pname = "rich";
32 version = "13.7.1";
33 format = "pyproject";
34
35 disabled = pythonOlder "3.7";
36
37 src = fetchFromGitHub {
38 owner = "Textualize";
39 repo = pname;
40 rev = "refs/tags/v${version}";
41 hash = "sha256-7LvmPrCpHfPEfJ1r8IFnQhYkBstvtIrWYhGwcchlc0s=";
42 };
43
44 nativeBuildInputs = [ poetry-core ];
45
46 propagatedBuildInputs = [
47 markdown-it-py
48 pygments
49 ] ++ lib.optionals (pythonOlder "3.9") [ typing-extensions ];
50
51 passthru.optional-dependencies = {
52 jupyter = [ ipywidgets ];
53 };
54
55 nativeCheckInputs = [
56 attrs
57 pytestCheckHook
58 setuptools
59 ];
60
61 disabledTests = [
62 # pygments 2.16 compat
63 # https://github.com/Textualize/rich/issues/3088
64 "test_card_render"
65 "test_markdown_render"
66 "test_markdown_render"
67 "test_python_render"
68 "test_python_render_simple"
69 "test_python_render_simple_passing_lexer_instance"
70 "test_python_render_indent_guides"
71 "test_option_no_wrap"
72 "test_syntax_highlight_ranges"
73 ];
74
75 pythonImportsCheck = [ "rich" ];
76
77 passthru.tests = {
78 inherit
79 enrich
80 httpie
81 rich-rst
82 textual
83 ;
84 };
85
86 meta = with lib; {
87 description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal";
88 homepage = "https://github.com/Textualize/rich";
89 changelog = "https://github.com/Textualize/rich/blob/v${version}/CHANGELOG.md";
90 license = licenses.mit;
91 maintainers = with maintainers; [
92 ris
93 joelkoen
94 ];
95 };
96}