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