Skip to content

How do we feel about adopting rich? #10423

Closed
@pradyunsg

Description

@pradyunsg

What's the problem this feature will solve?

We're currently using the logging module for handling our output needs. This... works, but is suboptimal since we don't really have any clean way to utilise all the flexibility that a terminal affords us; most notably colors and varying text presentations.

Describe the solution you'd like

Well, part of why I haven't pursued #6541 is that there's no real benefit to doing that without something genuinely beneficial from a UI/UX perspective with that flexibility on the other side.

There weren't any straightforward-and-major presentation gains to be made, by undertaking such a revamp. This is part of why I've let this loiter for so long. With rich though, we would have the required flexibility to actually make meaningful aesthetic improvements available with significantly lower effort (mostly because the required effort was already put into the library).

Alternative Solutions

Maintaining status quo is an option. So, is exploring alternatives to rich that might be more appropriate for our usecase.

I'm wary of directly using something low level though (eg: using colorama directly) since we'd either need to deal with the quirks of the terminal or reimplement many of the features that we'd get with a more rounded-out library like rich.

Additional context

We need to be mindful of our our distribution sizes.

-rw-r--r--  1 pradyunsg  staff   2.6M  3 Sep 10:44 pip-21.3.dev0+rich.tar.gz
-rw-r--r--  1 pradyunsg  staff   1.5M  3 Sep 10:44 pip-21.3.dev0.tar.gz

Most of this ocmes from pygments -- we'll likely need to do something to trim the styles and lexers (~4 MB uncompressed) which we can trim with our vendoring setup. IIUC we don't need any of the web-related styling and only need the lexers related to Markdown and Python.

We'd also need buy-in from the maintainers (/cc @willmcgugan) of rich, since this imposes a couple of restrictions on the library -- it can't adopt non-pure Python dependencies without a graceful fallback and that we're mindful of the sizes of the entire dependency tree.

I had a chat with him a few weeks ago where we talked about this, and he seemed hesitantly excited about the idea. :)

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions