Skip to content

Commit

Permalink
force recreation of venv if it is not sane (#286) (#1797)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

Co-authored-by: Sébastien Eustace <[email protected]>
  • Loading branch information
finswimmer and sdispater committed Jan 9, 2020
1 parent 4fe3c52 commit cbb1c18
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions poetry/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,10 @@ def create_venv(

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
Expand Down Expand Up @@ -606,6 +610,12 @@ def create_venv(
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))
)
Expand Down

0 comments on commit cbb1c18

Please sign in to comment.