Commit 33ab35dc authored by Andrew Svetlov's avatar Andrew Svetlov

Issue #15776: Allow pyvenv to work in existing directory with --clean.

Patch by Vinay Sajip.
parent cbff7d05
...@@ -105,7 +105,15 @@ class EnvBuilder: ...@@ -105,7 +105,15 @@ class EnvBuilder:
if os.path.exists(env_dir) and not (self.clear or self.upgrade): if os.path.exists(env_dir) and not (self.clear or self.upgrade):
raise ValueError('Directory exists: %s' % env_dir) raise ValueError('Directory exists: %s' % env_dir)
if os.path.exists(env_dir) and self.clear: if os.path.exists(env_dir) and self.clear:
shutil.rmtree(env_dir) # Issue 15776: To support running pyvenv on '.', the venv
# directory contents are emptied and recreated, instead of
# the venv directory being deleted and recreated.
for f in os.listdir(env_dir):
f = os.path.join(env_dir, f)
if os.path.isdir(f):
shutil.rmtree(f)
else:
os.remove(f)
context = Context() context = Context()
context.env_dir = env_dir context.env_dir = env_dir
context.env_name = os.path.split(env_dir)[1] context.env_name = os.path.split(env_dir)[1]
......
...@@ -29,6 +29,8 @@ Core and Builtins ...@@ -29,6 +29,8 @@ Core and Builtins
Library Library
------- -------
- Issue #15776: Allow pyvenv to work in existing directory with --clean.
- Issue #15249: BytesGenerator now correctly mangles From lines (when - Issue #15249: BytesGenerator now correctly mangles From lines (when
requested) even if the body contains undecodable bytes. requested) even if the body contains undecodable bytes.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment