mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Allow quieting the output of pipenv run and .env loading. (#5006)
* Restore this message as stderr because it affects requirements.txt generation. * Only load the dotenv file when its a real file and thus only print the message when its present. * Add news fragment. * Allow quieting the output of install and .env loading. * Missed this spot in th test to convert back. * Add news fragment for quiet run option.
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
It is now possible to silence the ``Loading .env environment variables`` message on ``pipenv run``
|
||||
with the ``--quiet`` flag or the `PIPENV_QUIET` environment variable.
|
||||
@@ -410,7 +410,13 @@ def run(state, command, args):
|
||||
"""Spawns a command installed into the virtualenv."""
|
||||
from ..core import do_run
|
||||
do_run(
|
||||
state.project, command=command, args=args, three=state.three, python=state.python, pypi_mirror=state.pypi_mirror
|
||||
state.project,
|
||||
command=command,
|
||||
args=args,
|
||||
three=state.three,
|
||||
python=state.python,
|
||||
pypi_mirror=state.pypi_mirror,
|
||||
quiet=state.quiet
|
||||
)
|
||||
|
||||
|
||||
@@ -444,11 +450,6 @@ def run(state, command, args):
|
||||
" vulnerabilities database. Leave blank for scanning against a"
|
||||
" database that only updates once a month.",
|
||||
)
|
||||
@option(
|
||||
"--quiet",
|
||||
is_flag=True,
|
||||
help="Quiet standard output, except vulnerability report."
|
||||
)
|
||||
@common_options
|
||||
@system_option
|
||||
@pass_state
|
||||
|
||||
@@ -408,6 +408,7 @@ def validate_pypi_mirror(ctx, param, value):
|
||||
def common_options(f):
|
||||
f = pypi_mirror_option(f)
|
||||
f = verbose_option(f)
|
||||
f = quiet_option(f)
|
||||
f = clear_option(f)
|
||||
f = three_option(f)
|
||||
f = python_option(f)
|
||||
|
||||
+4
-4
@@ -94,7 +94,7 @@ def do_clear(project):
|
||||
raise
|
||||
|
||||
|
||||
def load_dot_env(project, as_dict=False):
|
||||
def load_dot_env(project, as_dict=False, quiet=False):
|
||||
"""Loads .env file into sys.environ."""
|
||||
if not project.s.PIPENV_DONT_LOAD_ENV:
|
||||
# If the project doesn't exist yet, check current directory for a .env file
|
||||
@@ -115,7 +115,7 @@ def load_dot_env(project, as_dict=False):
|
||||
)
|
||||
if as_dict:
|
||||
return dotenv.dotenv_values(dotenv_file)
|
||||
elif os.path.isfile(dotenv_file):
|
||||
elif os.path.isfile(dotenv_file) and not quiet:
|
||||
click.echo(
|
||||
crayons.normal(fix_utf8("Loading .env environment variables..."), bold=True),
|
||||
err=True,
|
||||
@@ -2442,7 +2442,7 @@ def do_run_posix(project, script, command, env):
|
||||
)
|
||||
|
||||
|
||||
def do_run(project, command, args, three=None, python=False, pypi_mirror=None):
|
||||
def do_run(project, command, args, three=None, python=False, pypi_mirror=None, quiet=False):
|
||||
"""Attempt to run command either pulling from project or interpreting as executable.
|
||||
|
||||
Args are appended to the command in [scripts] section of project if found.
|
||||
@@ -2454,7 +2454,7 @@ def do_run(project, command, args, three=None, python=False, pypi_mirror=None):
|
||||
project, three=three, python=python, validate=False, pypi_mirror=pypi_mirror,
|
||||
)
|
||||
|
||||
load_dot_env(project)
|
||||
load_dot_env(project, quiet=quiet)
|
||||
env = os.environ.copy()
|
||||
env.pop("PIP_SHIMS_BASE_MODULE", None)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user