Skip to content

Commit

Permalink
fix(utils.env): import cli_run from virtualenv (#2096)
Browse files Browse the repository at this point in the history
* fix(utils.env): import cli_run from virtualenv if create_environment import failes

* fix (utils.env): added accidentally removed code
  • Loading branch information
finswimmer authored Feb 28, 2020
1 parent 15728ee commit 9306cd2
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions poetry/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,19 @@
from venv import EnvBuilder
builder = EnvBuilder(with_pip=True)
build = builder.create
builder.create(path)
except ImportError:
# We fallback on virtualenv for Python 2.7
from virtualenv import create_environment
try:
# We fallback on virtualenv for Python 2.7
from virtualenv import create_environment
build = create_environment
create_environment(path)
except ImportError:
# since virtualenv>20 we have to use cli_run
from virtualenv import cli_run
build(path)"""
cli_run([path])
"""


class EnvError(Exception):
Expand Down Expand Up @@ -668,14 +673,18 @@ def build_venv(cls, path, executable=None):
use_symlinks = True

builder = EnvBuilder(with_pip=True, symlinks=use_symlinks)
build = builder.create
builder.create(path)
except ImportError:
# We fallback on virtualenv for Python 2.7
from virtualenv import create_environment
try:
# We fallback on virtualenv for Python 2.7
from virtualenv import create_environment

build = create_environment
create_environment(path)
except ImportError:
# since virtualenv>20 we have to use cli_run
from virtualenv import cli_run

build(path)
cli_run([path])

def remove_venv(self, path): # type: (str) -> None
shutil.rmtree(path)
Expand Down

0 comments on commit 9306cd2

Please sign in to comment.