mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
clear the caches
This commit is contained in:
+11
-2
@@ -136,6 +136,7 @@ def validate_pypi_mirror(ctx, param, value):
|
||||
is_flag=True,
|
||||
help="Output diagnostic information for use in Github issues.",
|
||||
)
|
||||
@option("--clear", is_flag=True, help="Clears caches (pipenv, pip, and pip-tools).")
|
||||
@version_option(prog_name=crayons.normal("pipenv", bold=True), version=__version__)
|
||||
@pass_context
|
||||
def cli(
|
||||
@@ -154,6 +155,7 @@ def cli(
|
||||
completion=False,
|
||||
pypi_mirror=None,
|
||||
support=None,
|
||||
clear=False,
|
||||
):
|
||||
if completion: # Handle this ASAP to make shell startup fast.
|
||||
from . import shells
|
||||
@@ -180,6 +182,7 @@ def cli(
|
||||
cleanup_virtualenv,
|
||||
ensure_project,
|
||||
format_help,
|
||||
do_clear,
|
||||
)
|
||||
|
||||
if man:
|
||||
@@ -203,19 +206,24 @@ def cli(
|
||||
sys.exit(0)
|
||||
warn_in_virtualenv()
|
||||
if ctx.invoked_subcommand is None:
|
||||
# --where was passed...
|
||||
# --where was passed…
|
||||
if where:
|
||||
do_where(bare=True)
|
||||
sys.exit(0)
|
||||
elif py:
|
||||
do_py()
|
||||
sys.exit()
|
||||
# --support was passed...
|
||||
# --support was passed…
|
||||
elif support:
|
||||
from .help import get_pipenv_diagnostics
|
||||
|
||||
get_pipenv_diagnostics()
|
||||
sys.exit(0)
|
||||
# --clear was passed…
|
||||
elif clear:
|
||||
do_clear()
|
||||
sys.exit(0)
|
||||
|
||||
# --venv was passed...
|
||||
elif venv:
|
||||
# There is no virtualenv yet.
|
||||
@@ -270,6 +278,7 @@ def cli(
|
||||
warn=True,
|
||||
site_packages=site_packages,
|
||||
pypi_mirror=pypi_mirror,
|
||||
clear=clear,
|
||||
)
|
||||
# Check this again before exiting for empty ``pipenv`` command.
|
||||
elif ctx.invoked_subcommand is None:
|
||||
|
||||
@@ -122,6 +122,18 @@ def which(command, location=None, allow_global=False):
|
||||
project = Project(which=which)
|
||||
|
||||
|
||||
def do_clear():
|
||||
click.echo(crayons.white("Clearing caches…", bold=True))
|
||||
import pip._internal.locations
|
||||
import piptools
|
||||
|
||||
try:
|
||||
shutil.rmtree(PIPENV_CACHE_DIR)
|
||||
shutil.rmtree(pip._internal.locations.USER_CACHE_DIR)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
|
||||
def load_dot_env():
|
||||
"""Loads .env file into sys.environ."""
|
||||
if not PIPENV_DONT_LOAD_ENV:
|
||||
@@ -582,10 +594,16 @@ def ensure_project(
|
||||
deploy=False,
|
||||
skip_requirements=False,
|
||||
pypi_mirror=None,
|
||||
clear=False,
|
||||
):
|
||||
"""Ensures both Pipfile and virtualenv exist for the project."""
|
||||
from .environments import PIPENV_USE_SYSTEM
|
||||
|
||||
# Clear the caches, if appropriate.
|
||||
if clear:
|
||||
print("clearing")
|
||||
sys.exit(1)
|
||||
|
||||
# Automatically use an activated virtualenv.
|
||||
if PIPENV_USE_SYSTEM:
|
||||
system = True
|
||||
|
||||
Reference in New Issue
Block a user