make in_env part of the language api

This commit is contained in:
Anthony Sottile
2023-01-02 19:02:38 -05:00
parent bcf0230772
commit ae34a962d7
23 changed files with 73 additions and 92 deletions

View File

@@ -59,12 +59,9 @@ def get_env_patch(target_dir: str) -> PatchesT: # pragma: win32 no cover
)
@contextlib.contextmanager
def in_env(
prefix: Prefix,
language_version: str,
) -> Generator[None, None, None]: # pragma: win32 no cover
envdir = helpers.environment_dir(prefix, ENVIRONMENT_DIR, language_version)
@contextlib.contextmanager # pragma: win32 no cover
def in_env(prefix: Prefix, version: str) -> Generator[None, None, None]:
envdir = helpers.environment_dir(prefix, ENVIRONMENT_DIR, version)
with envcontext(get_env_patch(envdir)):
yield
@@ -74,5 +71,4 @@ def run_hook(
file_args: Sequence[str],
color: bool,
) -> tuple[int, bytes]: # pragma: win32 no cover
with in_env(hook.prefix, hook.language_version):
return helpers.run_xargs(hook, hook.cmd, file_args, color=color)
return helpers.run_xargs(hook, hook.cmd, file_args, color=color)