spinner: allow disabling or overriding

This commit is contained in:
Oz Tiram
2022-11-14 00:01:02 +01:00
parent 0bd03e62b6
commit 74b64f8bae
4 changed files with 21 additions and 36 deletions
+7 -8
View File
@@ -249,8 +249,9 @@ def ensure_pipfile(project, validate=True, skip_requirements=False, system=False
)
# Create a Pipfile...
project.create_pipfile(python=python)
# TODO: pass project settings to status here
with console.status("Importing requirements...") as st:
with console.status(
"Importing requirements...", spinner=project.s.PIPENV_SPINNER
) as st:
# Import requirements.txt.
try:
import_requirements(project)
@@ -1009,8 +1010,9 @@ def do_create_virtualenv(project, python=None, site_packages=None, pypi_mirror=N
# Actually create the virtualenv.
error = None
# TODO: update project setting here
with console.status("Creating virtual environment..."):
with console.status(
"Creating virtual environment...", spinner=project.s.PIPENV_SPINNER
):
c = subprocess_run(cmd, env=pip_config)
click.secho(f"{c.stdout}", fg="cyan", err=True)
if c.returncode != 0:
@@ -2292,11 +2294,8 @@ def do_install(
bold=True,
)
# pip install:
# TODO: console.status() accepts:
# spinner='dots', spinner_style='status.spinner'
# we should use pipenv.project.settings to configure these.
with vistir.contextmanagers.temp_environ(), console.status(
"Installing..."
"Installing...", spinner=project.s.PIPENV_SPINNER
) as st:
if not system:
os.environ["PIP_USER"] = "0"
+13 -6
View File
@@ -218,14 +218,21 @@ class Setting:
if PIPENV_IS_CI:
self.PIPENV_NOSPIN = True
pipenv_spinner = "dots" if not os.name == "nt" else "bouncingBar"
self.PIPENV_SPINNER = get_from_env(
"SPINNER", check_for_negation=False, default=pipenv_spinner
)
if self.PIPENV_NOSPIN:
from pipenv.patched.pip._vendor.rich import _spinners
_spinners.SPINNERS[None] = {"interval": 80, "frames": " "}
self.PIPENV_SPINNER = None
else:
pipenv_spinner = "dots" if not os.name == "nt" else "bouncingBar"
self.PIPENV_SPINNER = get_from_env(
"SPINNER", check_for_negation=False, default=pipenv_spinner
)
"""Sets the default spinner type.
Spinners are identical to the ``node.js`` spinners and can be found at
https://github.com/sindresorhus/cli-spinners
You can see which spinners are available by running::
$ python -m pipenv.patched.pip._vendor.rich.spinner
"""
pipenv_pipfile = get_from_env("PIPFILE", check_for_negation=False)
+1 -2
View File
@@ -1027,8 +1027,7 @@ def venv_resolve_deps(
os.environ.pop("PIPENV_SITE_DIR", None)
if keep_outdated:
os.environ["PIPENV_KEEP_OUTDATED"] = "1"
# TODO: add settings to console.status
with console.status("Locking...") as st:
with console.status("Locking...", spinner=project.s.PIPENV_SPINNER) as st:
# This conversion is somewhat slow on local and file-type requirements since
# we now download those requirements / make temporary folders to perform
# dependency resolution on them, so we are including this step inside the
-20
View File
@@ -1,20 +0,0 @@
import contextlib
@contextlib.contextmanager
def create_spinner(text, setting, nospin=None, spinner_name=None):
from pipenv.vendor.vistir import spin
if not spinner_name:
spinner_name = setting.PIPENV_SPINNER
if nospin is None:
nospin = setting.PIPENV_NOSPIN
with spin.create_spinner(
spinner_name=spinner_name,
start_text=text,
nospin=nospin,
write_to_stdout=False,
) as sp:
yield sp