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