summaryrefslogtreecommitdiffstats
path: root/third_party/python/pip-tools/piptools/locations.py
blob: 9ca0ffe4367e4171bd10bc60836e6e374d2be2ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import os
from shutil import rmtree

from pip._internal.utils.appdirs import user_cache_dir

from .click import secho

# The user_cache_dir helper comes straight from pip itself
CACHE_DIR = user_cache_dir("pip-tools")

# NOTE
# We used to store the cache dir under ~/.pip-tools, which is not the
# preferred place to store caches for any platform.  This has been addressed
# in pip-tools==1.0.5, but to be good citizens, we point this out explicitly
# to the user when this directory is still found.
LEGACY_CACHE_DIR = os.path.expanduser("~/.pip-tools")

if os.path.exists(LEGACY_CACHE_DIR):
    secho(
        "Removing old cache dir {} (new cache dir is {})".format(
            LEGACY_CACHE_DIR, CACHE_DIR
        ),
        fg="yellow",
    )
    rmtree(LEGACY_CACHE_DIR)