From 4f47bdcdf7fddfed106bd546d5a0d0816510f9e3 Mon Sep 17 00:00:00 2001 From: Stephen Kent Date: Mon, 4 Mar 2024 21:16:07 -0800 Subject: [PATCH] Use temp dir for Poetry cache directory in manage-cookie This prevents Poetry from creating permanent virtualenvs in the user's cache directory when using manage-cookie --- cookie_python/manage/repo.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cookie_python/manage/repo.py b/cookie_python/manage/repo.py index 80db300..934ae65 100644 --- a/cookie_python/manage/repo.py +++ b/cookie_python/manage/repo.py @@ -69,6 +69,12 @@ def tempdir(self) -> Path: ) ) + @cached_property + def cachedir(self) -> Path: + d = self.tempdir / "cache" + d.mkdir(exist_ok=True) + return d + @cached_property def clone_path(self) -> Path: subprocess.run( @@ -99,6 +105,7 @@ def run( kwargs["env"].setdefault( "PYTHON_KEYRING_BACKEND", "keyring.backends.null.Keyring" ) + kwargs["env"].setdefault("POETRY_CACHE_DIR", self.cachedir) return subprocess.run(*popenargs, check=check, **kwargs) def shell(self) -> None: