From b2646cb5c0c9c9690fd94123896d9603b148014a Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 23 Jan 2015 13:23:33 +0100 Subject: [PATCH] Check if venv already exists. According to the documentation, Python should do that already: If the target directory already exists an error will be raised, unless the --clear or --upgrade option was provided. However that doesn't seem to be the case: http://bugs.python.org/issue23202 We do this by hand to make sure the user doesn't accidentally overwrite something. See #463. --- scripts/init_venv.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/init_venv.py b/scripts/init_venv.py index 3ab0caaeb..e847741c7 100644 --- a/scripts/init_venv.py +++ b/scripts/init_venv.py @@ -164,6 +164,12 @@ def main(): sys.exit(1) g_path = os.path.abspath(g_args.path) + if os.path.exists(g_args.path) and not (g_args.force or g_args.clear or + g_args.upgrade): + print("{} does already exist! Use --clear or " + "--upgrade.".format(g_path), file=sys.stderr) + sys.exit(1) + create_venv() utils.print_title("Installing setuptools")