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): ...@@ -473,6 +473,10 @@ class EnvManager(object):
cwd = self._poetry.file.parent cwd = self._poetry.file.parent
env = self.get(reload=True) env = self.get(reload=True)
if not env.is_sane():
force = True
if env.is_venv() and not force: if env.is_venv() and not force:
# Already inside a virtualenv. # Already inside a virtualenv.
return env return env
...@@ -606,6 +610,12 @@ class EnvManager(object): ...@@ -606,6 +610,12 @@ class EnvManager(object):
self.build_venv(str(venv), executable=executable) self.build_venv(str(venv), executable=executable)
else: else:
if force: 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( io.write_line(
"Recreating virtualenv <c1>{}</> in {}".format(name, str(venv)) "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