Commit cbb1c181 by finswimmer Committed by Sébastien Eustace

force recreation of venv if it is not sane (#286) (#1797)

* change (env.py): force recreation of venv if it is not sane

* new (env): add warning when forcing recreation

* fix (env): warning about broken venv placed right before calling recreation

* Update poetry/utils/env.py

Co-Authored-By: Sébastien Eustace <sebastien.eustace@gmail.com>

Co-authored-by: Sébastien Eustace <sebastien.eustace@gmail.com>
parent 4fe3c527
......@@ -473,6 +473,10 @@ class EnvManager(object):
cwd = self._poetry.file.parent
env = self.get(reload=True)
if not env.is_sane():
force = True
if env.is_venv() and not force:
# Already inside a virtualenv.
return env
......@@ -606,6 +610,12 @@ class EnvManager(object):
self.build_venv(str(venv), executable=executable)
else:
if force:
if not env.is_sane():
io.write_line(
"<warning>The virtual environment found in {} seems to be broken.</warning>".format(
env.path
)
)
io.write_line(
"Recreating virtualenv <c1>{}</> in {}".format(name, str(venv))
)
......
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