Skip to content

Commit

Permalink
change (utils.cache): renamed utils.cache to utils.temp to avoid nami…
Browse files Browse the repository at this point in the history
…ng confusion to poetries repository caching system

change (utils.temp): renamed DownloadCache to DownloadTmpDir
  • Loading branch information
finswimmer committed Mar 17, 2020
1 parent bbd7f3a commit e979d3e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
6 changes: 4 additions & 2 deletions poetry/installation/pip_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from poetry.repositories.pool import Pool
from poetry.utils._compat import Path
from poetry.utils._compat import encode
from poetry.utils.cache import DownloadCache
from poetry.utils.env import Env
from poetry.utils.helpers import safe_rmtree
from poetry.utils.temp import DownloadTmpDir

from .base_installer import BaseInstaller

Expand Down Expand Up @@ -236,7 +236,9 @@ def install_git(self, package):
from poetry.vcs import Git

src_dir = self._env.path / "src" / package.name
tmp_dir = Path(DownloadCache.mkcache(package.source_url, prefix="pypoetry-git"))
tmp_dir = Path(
DownloadTmpDir.mkcache(package.source_url, prefix="pypoetry-git")
)

if src_dir.exists():
safe_rmtree(str(src_dir))
Expand Down
4 changes: 2 additions & 2 deletions poetry/puzzle/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
from poetry.utils._compat import OrderedDict
from poetry.utils._compat import Path
from poetry.utils._compat import urlparse
from poetry.utils.cache import DownloadCache
from poetry.utils.env import EnvCommandError
from poetry.utils.env import EnvManager
from poetry.utils.env import VirtualEnv
from poetry.utils.helpers import parse_requires
from poetry.utils.helpers import temporary_directory
from poetry.utils.inspector import Inspector
from poetry.utils.setup_reader import SetupReader
from poetry.utils.temp import DownloadTmpDir
from poetry.utils.toml_file import TomlFile
from poetry.vcs.git import Git
from poetry.version.markers import MarkerUnion
Expand Down Expand Up @@ -186,7 +186,7 @@ def get_package_from_vcs(
if vcs != "git":
raise ValueError("Unsupported VCS dependency {}".format(vcs))

tmp_dir = Path(DownloadCache.mkcache(url, prefix="pypoetry-git"))
tmp_dir = Path(DownloadTmpDir.mkcache(url, prefix="pypoetry-git"))

git = Git()

Expand Down
14 changes: 7 additions & 7 deletions poetry/utils/cache.py → poetry/utils/temp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ def force_rm(action, name, exc):


@atexit.register
def cleanup_caches():
for source, cache in DownloadCache.cache_dirs.items():
def cleanup_tmp():
for source, cache in DownloadTmpDir.tmp_dirs.items():
shutil.rmtree(cache, onerror=force_rm)


class DownloadCache:
cache_dirs = {}
class DownloadTmpDir:
tmp_dirs = {}

@classmethod
def mkcache(cls, source, suffix="", prefix="", dir=""):
if source not in cls.cache_dirs:
cls.cache_dirs[source] = mkdtemp(suffix, prefix, dir)
if source not in cls.tmp_dirs:
cls.tmp_dirs[source] = mkdtemp(suffix, prefix, dir)

return cls.cache_dirs[source]
return cls.tmp_dirs[source]

0 comments on commit e979d3e

Please sign in to comment.