Skip to content

Commit

Permalink
copy ephemeral_environment function from 6400f42
Browse files Browse the repository at this point in the history
  • Loading branch information
robin92 committed Feb 15, 2022
1 parent be1f1ef commit e0edf85
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions poetry/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from poetry.utils._compat import subprocess
from poetry.utils.helpers import is_dir_writable
from poetry.utils.helpers import paths_csv
from poetry.utils.helpers import temporary_directory


GET_ENVIRONMENT_INFO = """\
Expand Down Expand Up @@ -1598,6 +1599,21 @@ def _bin(self, bin):
return bin


@contextmanager
def ephemeral_environment(executable=None, pip=False, wheel=None, setuptools=None):
with temporary_directory() as tmp_dir:
# TODO: cache PEP 517 build environment corresponding to each project venv
venv_dir = Path(tmp_dir) / ".venv"
EnvManager.build_venv(
path=venv_dir.as_posix(),
executable=executable,
with_pip=pip,
with_wheel=wheel,
with_setuptools=setuptools,
)
yield VirtualEnv(venv_dir, venv_dir)


class MockEnv(NullEnv):
def __init__(
self,
Expand Down

0 comments on commit e0edf85

Please sign in to comment.