mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Add wrapper function to PIPENV_VERBOSITY
This commit is contained in:
+9
-9
@@ -647,7 +647,7 @@ def do_install_dependencies(
|
||||
c.block()
|
||||
if "Ignoring" in c.out:
|
||||
click.echo(crayons.yellow(c.out.strip()))
|
||||
elif environments.PIPENV_VERBOSITY > 0:
|
||||
elif environments.is_verbose():
|
||||
click.echo(crayons.blue(c.out or c.err))
|
||||
# The Installation failed…
|
||||
if c.return_code != 0:
|
||||
@@ -1105,7 +1105,7 @@ def do_purge(bare=False, downloads=False, allow_global=False):
|
||||
escape_grouped_arguments(which_pip(allow_global=allow_global)),
|
||||
" ".join(actually_installed),
|
||||
)
|
||||
if environments.PIPENV_VERBOSITY > 0:
|
||||
if environments.is_verbose():
|
||||
click.echo("$ {0}".format(command))
|
||||
c = delegator.run(command)
|
||||
if not bare:
|
||||
@@ -1257,7 +1257,7 @@ def pip_install(
|
||||
from notpip._vendor.pyparsing import ParseException
|
||||
from .vendor.requirementslib import Requirement
|
||||
|
||||
if environments.PIPENV_VERBOSITY > 0:
|
||||
if environments.is_verbose():
|
||||
click.echo(
|
||||
crayons.normal("Installing {0!r}".format(package_name), bold=True), err=True
|
||||
)
|
||||
@@ -1351,13 +1351,13 @@ def pip_install(
|
||||
),
|
||||
"sources": " ".join(prepare_pip_source_args(sources)),
|
||||
"src": src,
|
||||
"verbose_flag": "--verbose" if environments.PIPENV_VERBOSITY > 0 else "",
|
||||
"verbose_flag": "--verbose" if environments.is_verbose() else "",
|
||||
"install_reqs": install_reqs
|
||||
}
|
||||
pip_command = "{quoted_pip} install {pre} {src} {verbose_flag} {upgrade_strategy} {no_deps} {install_reqs} {sources}".format(
|
||||
**pip_args
|
||||
)
|
||||
if environments.PIPENV_VERBOSITY > 0:
|
||||
if environments.is_verbose():
|
||||
click.echo("$ {0}".format(pip_command), err=True)
|
||||
cache_dir = Path(PIPENV_CACHE_DIR)
|
||||
pip_config = {
|
||||
@@ -1526,8 +1526,8 @@ def format_pip_output(out, r=None):
|
||||
def warn_in_virtualenv():
|
||||
# Only warn if pipenv isn't already active.
|
||||
pipenv_active = os.environ.get("PIPENV_ACTIVE")
|
||||
if ((environments.PIPENV_USE_SYSTEM or environments.PIPENV_VIRTUALENV)
|
||||
and not (pipenv_active or environments.PIPENV_VERBOSITY < 0)):
|
||||
if ((environments.PIPENV_USE_SYSTEM or environments.PIPENV_VIRTUALENV) and
|
||||
not (pipenv_active or environments.is_quiet())):
|
||||
click.echo(
|
||||
"{0}: Pipenv found itself running within a virtual environment, "
|
||||
"so it will automatically use that environment, instead of "
|
||||
@@ -1976,7 +1976,7 @@ def do_uninstall(
|
||||
cmd = "{0} uninstall {1} -y".format(
|
||||
escape_grouped_arguments(which_pip(allow_global=system)), package_name
|
||||
)
|
||||
if environments.PIPENV_VERBOSITY > 0:
|
||||
if environments.is_verbose():
|
||||
click.echo("$ {0}".format(cmd))
|
||||
c = delegator.run(cmd)
|
||||
click.echo(crayons.blue(c.out))
|
||||
@@ -2455,7 +2455,7 @@ def do_clean(
|
||||
# Remove known "bad packages" from the list.
|
||||
for bad_package in BAD_PACKAGES:
|
||||
if bad_package in installed_package_names:
|
||||
if environments.PIPENV_VERBOSITY > 0:
|
||||
if environments.is_verbose():
|
||||
click.echo("Ignoring {0}.".format(repr(bad_package)), err=True)
|
||||
del installed_package_names[installed_package_names.index(bad_package)]
|
||||
# Intelligently detect if --dev should be used or not.
|
||||
|
||||
@@ -189,6 +189,14 @@ if interactive.
|
||||
"""
|
||||
|
||||
|
||||
def is_verbose(threshold=1):
|
||||
return PIPENV_VERBOSITY >= threshold
|
||||
|
||||
|
||||
def is_quiet(threshold=-1):
|
||||
return PIPENV_VERBOSITY <= threshold
|
||||
|
||||
|
||||
# Internal, support running in a different Python from sys.executable.
|
||||
PIPENV_PYTHON = os.environ.get("PIPENV_PYTHON")
|
||||
|
||||
|
||||
+6
-6
@@ -270,7 +270,7 @@ def actually_resolve_deps(
|
||||
pip_args = []
|
||||
if sources:
|
||||
pip_args = prepare_pip_source_args(sources, pip_args)
|
||||
if environments.PIPENV_VERBOSITY > 0:
|
||||
if environments.is_verbose():
|
||||
print("Using pip: {0}".format(" ".join(pip_args)))
|
||||
with NamedTemporaryFile(
|
||||
mode="w",
|
||||
@@ -293,7 +293,7 @@ def actually_resolve_deps(
|
||||
constraints_file, finder=pypi.finder, session=pypi.session, options=pip_options
|
||||
)
|
||||
constraints = [c for c in constraints]
|
||||
if environments.PIPENV_VERBOSITY > 0:
|
||||
if environments.is_verbose():
|
||||
logging.log.verbose = True
|
||||
piptools_logging.log.verbose = True
|
||||
resolved_tree = set()
|
||||
@@ -356,7 +356,7 @@ def venv_resolve_deps(
|
||||
escape_grouped_arguments(which("python", allow_global=allow_global)),
|
||||
resolver,
|
||||
"--pre" if pre else "",
|
||||
"--verbose" if (environments.PIPENV_VERBOSITY > 0) else "",
|
||||
"--verbose" if (environments.is_verbose()) else "",
|
||||
"--clear" if clear else "",
|
||||
"--system" if allow_global else "",
|
||||
)
|
||||
@@ -368,13 +368,13 @@ def venv_resolve_deps(
|
||||
try:
|
||||
assert c.return_code == 0
|
||||
except AssertionError:
|
||||
if environments.PIPENV_VERBOSITY > 0:
|
||||
if environments.is_verbose():
|
||||
click_echo(c.out, err=True)
|
||||
click_echo(c.err, err=True)
|
||||
else:
|
||||
click_echo(c.err[(int(len(c.err) / 2) - 1):], err=True)
|
||||
sys.exit(c.return_code)
|
||||
if environments.PIPENV_VERBOSITY > 0:
|
||||
if environments.is_verbose():
|
||||
click_echo(c.out.split("RESULTS:")[0], err=True)
|
||||
try:
|
||||
return json.loads(c.out.split("RESULTS:")[1].strip())
|
||||
@@ -479,7 +479,7 @@ def resolve_deps(
|
||||
collected_hashes.append(release["digests"]["sha256"])
|
||||
collected_hashes = ["sha256:" + s for s in collected_hashes]
|
||||
except (ValueError, KeyError, ConnectionError):
|
||||
if environments.PIPENV_VERBOSITY > 0:
|
||||
if environments.is_verbose():
|
||||
click_echo(
|
||||
"{0}: Error generating hash for {1}".format(
|
||||
crayons.red("Warning", bold=True), name
|
||||
|
||||
Reference in New Issue
Block a user