From 41bf02f863d4950859637ab07b3948c2269e61a8 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 27 Jul 2019 14:20:47 -0700 Subject: [PATCH] Improve recreate check by looking for .tox-config1 --- docs/changelog/1383.bugfix.rst | 1 + src/tox/venv.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 docs/changelog/1383.bugfix.rst diff --git a/docs/changelog/1383.bugfix.rst b/docs/changelog/1383.bugfix.rst new file mode 100644 index 000000000..3445944ba --- /dev/null +++ b/docs/changelog/1383.bugfix.rst @@ -0,0 +1 @@ +improve recreate check by allowing directories containing ``.tox-config1`` (the marker file created by tox) - by :user:`asottile` diff --git a/src/tox/venv.py b/src/tox/venv.py index 607f8a84a..04fc14617 100644 --- a/src/tox/venv.py +++ b/src/tox/venv.py @@ -698,7 +698,7 @@ def cleanup_for_venv(venv): # an error if venv.path.exists(): dir_items = set(os.listdir(str(venv.path))) - {".lock", "log"} - dir_items = {p for p in dir_items if not p.startswith(".tox-")} + dir_items = {p for p in dir_items if not p.startswith(".tox-") or p == ".tox-config1"} else: dir_items = set() @@ -707,6 +707,8 @@ def cleanup_for_venv(venv): not venv.path.exists() # does exist, but it's empty => OK or not dir_items + # tox has marked this as an environment it has created in the past + or ".tox-config1" in dir_items # it exists and we're on windows with Lib and Scripts => OK or (INFO.IS_WIN and dir_items > {"Scripts", "Lib"}) # non-windows, with lib and bin => OK