Skip to content

Add rich based spinner #13451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

ichard26
Copy link
Member

@ichard26 ichard26 commented Jun 27, 2025

Broken out of #13450. Our legacy spinners can't be used for that PR because they require that their spin() method is called manually (and thus are only really functional with the subprocess utility). Instead, let rich handle the updates in the background for us.

Can be tested manually like so:

import time
import logging.config  # this is a bug with pip's logging stack
from pip._internal.cli.spinners import open_rich_spinner
from pip._internal.utils.logging import setup_logging

setup_logging(0, no_color=False, user_log_file=None)
with open_rich_spinner("doing work"):
		time.sleep(2)
try:
		with open_rich_spinner("doing work"):
				1/0
except BaseException:
		pass
try:
		with open_rich_spinner("doing work"):
				raise KeyboardInterrupt
except BaseException:
		pass

@ichard26 ichard26 added skip news Does not need a NEWS file entry (eg: trivial changes) C: output Related to what pip prints labels Jun 27, 2025
The benefit of this spinner over our legacy spinners is that Rich will
update and render the spinner automatically for us. This is much nicer
than having to call .spin() manually.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: output Related to what pip prints skip news Does not need a NEWS file entry (eg: trivial changes)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant