# Path: pre_commit/envcontext.py
# @contextlib.contextmanager
# def envcontext(
#         patch: PatchesT,
#         _env: MutableMapping[str, str] | None = None,
# ) -> Generator[None, None, None]:
#     """In this context, `os.environ` is modified according to `patch`.
# 
#     `patch` is an iterable of 2-tuples (key, value):
#         `key`: string
#         `value`:
#             - string: `environ[key] == value` inside the context.
#             - UNSET: `key not in environ` inside the context.
#             - template: A template is a tuple of strings and Var which will be
#               replaced with the previous environment
#     """
#     env = os.environ if _env is None else _env
#     before = dict(env)
# 
#     for k, v in patch:
#         if v is UNSET:
#             env.pop(k, None)
#         elif isinstance(v, tuple):
#             env[k] = format_env(v, before)
#         else:
#             env[k] = v
# 
#     try:
#         yield
#     finally:
#         env.clear()
#         env.update(before)
# 
# Path: pre_commit/envcontext.py
# UNSET = _Unset.UNSET
# class Var(NamedTuple):
# def format_env(parts: SubstitutionT, env: MutableMapping[str, str]) -> str:
# def envcontext(
#         patch: PatchesT,
#         _env: MutableMapping[str, str] | None = None,
# ) -> Generator[None, None, None]:
# 
# Path: pre_commit/envcontext.py
# class Var(NamedTuple):
#     name: str
#     default: str = ''
# 
# Path: pre_commit/hook.py
# class Hook(NamedTuple):
#     src: str
#     prefix: Prefix
#     id: str
#     name: str
#     entry: str
#     language: str
#     alias: str
#     files: str
#     exclude: str
#     types: Sequence[str]
#     types_or: Sequence[str]
#     exclude_types: Sequence[str]
#     additional_dependencies: Sequence[str]
#     args: Sequence[str]
#     always_run: bool
#     fail_fast: bool
#     pass_filenames: bool
#     description: str
#     language_version: str
#     log_file: str
#     minimum_pre_commit_version: str
#     require_serial: bool
#     stages: Sequence[str]
#     verbose: bool
# 
#     @property
#     def cmd(self) -> tuple[str, ...]:
#         return (*shlex.split(self.entry), *self.args)
# 
#     @property
#     def install_key(self) -> tuple[Prefix, str, str, tuple[str, ...]]:
#         return (
#             self.prefix,
#             self.language,
#             self.language_version,
#             tuple(self.additional_dependencies),
#         )
# 
#     @classmethod
#     def create(cls, src: str, prefix: Prefix, dct: dict[str, Any]) -> Hook:
#         # TODO: have cfgv do this (?)
#         extra_keys = set(dct) - _KEYS
#         if extra_keys:
#             logger.warning(
#                 f'Unexpected key(s) present on {src} => {dct["id"]}: '
#                 f'{", ".join(sorted(extra_keys))}',
#             )
#         return cls(src=src, prefix=prefix, **{k: dct[k] for k in _KEYS})
# 
# Path: pre_commit/languages/helpers.py
# FIXED_RANDOM_SEED = 1542676187
# SHIMS_RE = re.compile(r'[/\\]shims[/\\]')
# def exe_exists(exe: str) -> bool:
# def run_setup_cmd(prefix: Prefix, cmd: tuple[str, ...], **kwargs: Any) -> None:
# def environment_dir(d: None, language_version: str) -> None: ...
# def environment_dir(d: str, language_version: str) -> str: ...
# def environment_dir(d: str | None, language_version: str) -> str | None:
# def assert_version_default(binary: str, version: str) -> None:
# def assert_no_additional_deps(
#         lang: str,
#         additional_deps: Sequence[str],
# ) -> None:
# def basic_get_default_version() -> str:
# def basic_healthy(prefix: Prefix, language_version: str) -> bool:
# def no_install(
#         prefix: Prefix,
#         version: str,
#         additional_dependencies: Sequence[str],
# ) -> NoReturn:
# def target_concurrency(hook: Hook) -> int:
# def _shuffled(seq: Sequence[str]) -> list[str]:
# def run_xargs(
#         hook: Hook,
#         cmd: tuple[str, ...],
#         file_args: Sequence[str],
#         **kwargs: Any,
# ) -> tuple[int, bytes]:
# 
# Path: pre_commit/prefix.py
# class Prefix(NamedTuple):
#     prefix_dir: str
# 
#     def path(self, *parts: str) -> str:
#         return os.path.normpath(os.path.join(self.prefix_dir, *parts))
# 
#     def exists(self, *parts: str) -> bool:
#         return os.path.exists(self.path(*parts))
# 
#     def star(self, end: str) -> tuple[str, ...]:
#         paths = os.listdir(self.prefix_dir)
#         return tuple(path for path in paths if path.endswith(end))
# 
# Path: pre_commit/util.py
# @contextlib.contextmanager
# def clean_path_on_failure(path: str) -> Generator[None, None, None]:
#     """Cleans up the directory on an exceptional failure."""
#     try:
#         yield
#     except BaseException:
#         if os.path.exists(path):
#             rmtree(path)
#         raise


import contextlib
import os
import shlex
from typing import Generator
from typing import Sequence
from pre_commit.envcontext import envcontext
from pre_commit.envcontext import PatchesT
from pre_commit.envcontext import Var
from pre_commit.hook import Hook
from pre_commit.languages import helpers
from pre_commit.prefix import Prefix
from pre_commit.util import clean_path_on_failure
from __future__ import annotations



ENVIRONMENT_DIR = 'perl_env'
get_default_version = helpers.basic_get_default_version
healthy = helpers.basic_healthy


def _envdir(prefix: Prefix, version: str) -> str:
    directory = helpers.environment_dir(ENVIRONMENT_DIR, version)
    return prefix.path(directory)


def get_env_patch(venv: str) -> PatchesT:
    return (

# Path: pre_commit/envcontext.py
# @contextlib.contextmanager
# def envcontext(
#         patch: PatchesT,
#         _env: MutableMapping[str, str] | None = None,
# ) -> Generator[None, None, None]:
#     """In this context, `os.environ` is modified according to `patch`.
# 
#     `patch` is an iterable of 2-tuples (key, value):
#         `key`: string
#         `value`:
#             - string: `environ[key] == value` inside the context.
#             - UNSET: `key not in environ` inside the context.
#             - template: A template is a tuple of strings and Var which will be
#               replaced with the previous environment
#     """
#     env = os.environ if _env is None else _env
#     before = dict(env)
# 
#     for k, v in patch:
#         if v is UNSET:
#             env.pop(k, None)
#         elif isinstance(v, tuple):
#             env[k] = format_env(v, before)
#         else:
#             env[k] = v
# 
#     try:
#         yield
#     finally:
#         env.clear()
#         env.update(before)
# 
# Path: pre_commit/envcontext.py
# UNSET = _Unset.UNSET
# class Var(NamedTuple):
# def format_env(parts: SubstitutionT, env: MutableMapping[str, str]) -> str:
# def envcontext(
#         patch: PatchesT,
#         _env: MutableMapping[str, str] | None = None,
# ) -> Generator[None, None, None]:
# 
# Path: pre_commit/envcontext.py
# class Var(NamedTuple):
#     name: str
#     default: str = ''
# 
# Path: pre_commit/hook.py
# class Hook(NamedTuple):
#     src: str
#     prefix: Prefix
#     id: str
#     name: str
#     entry: str
#     language: str
#     alias: str
#     files: str
#     exclude: str
#     types: Sequence[str]
#     types_or: Sequence[str]
#     exclude_types: Sequence[str]
#     additional_dependencies: Sequence[str]
#     args: Sequence[str]
#     always_run: bool
#     fail_fast: bool
#     pass_filenames: bool
#     description: str
#     language_version: str
#     log_file: str
#     minimum_pre_commit_version: str
#     require_serial: bool
#     stages: Sequence[str]
#     verbose: bool
# 
#     @property
#     def cmd(self) -> tuple[str, ...]:
#         return (*shlex.split(self.entry), *self.args)
# 
#     @property
#     def install_key(self) -> tuple[Prefix, str, str, tuple[str, ...]]:
#         return (
#             self.prefix,
#             self.language,
#             self.language_version,
#             tuple(self.additional_dependencies),
#         )
# 
#     @classmethod
#     def create(cls, src: str, prefix: Prefix, dct: dict[str, Any]) -> Hook:
#         # TODO: have cfgv do this (?)
#         extra_keys = set(dct) - _KEYS
#         if extra_keys:
#             logger.warning(
#                 f'Unexpected key(s) present on {src} => {dct["id"]}: '
#                 f'{", ".join(sorted(extra_keys))}',
#             )
#         return cls(src=src, prefix=prefix, **{k: dct[k] for k in _KEYS})
# 
# Path: pre_commit/languages/helpers.py
# FIXED_RANDOM_SEED = 1542676187
# SHIMS_RE = re.compile(r'[/\\]shims[/\\]')
# def exe_exists(exe: str) -> bool:
# def run_setup_cmd(prefix: Prefix, cmd: tuple[str, ...], **kwargs: Any) -> None:
# def environment_dir(d: None, language_version: str) -> None: ...
# def environment_dir(d: str, language_version: str) -> str: ...
# def environment_dir(d: str | None, language_version: str) -> str | None:
# def assert_version_default(binary: str, version: str) -> None:
# def assert_no_additional_deps(
#         lang: str,
#         additional_deps: Sequence[str],
# ) -> None:
# def basic_get_default_version() -> str:
# def basic_healthy(prefix: Prefix, language_version: str) -> bool:
# def no_install(
#         prefix: Prefix,
#         version: str,
#         additional_dependencies: Sequence[str],
# ) -> NoReturn:
# def target_concurrency(hook: Hook) -> int:
# def _shuffled(seq: Sequence[str]) -> list[str]:
# def run_xargs(
#         hook: Hook,
#         cmd: tuple[str, ...],
#         file_args: Sequence[str],
#         **kwargs: Any,
# ) -> tuple[int, bytes]:
# 
# Path: pre_commit/prefix.py
# class Prefix(NamedTuple):
#     prefix_dir: str
# 
#     def path(self, *parts: str) -> str:
#         return os.path.normpath(os.path.join(self.prefix_dir, *parts))
# 
#     def exists(self, *parts: str) -> bool:
#         return os.path.exists(self.path(*parts))
# 
#     def star(self, end: str) -> tuple[str, ...]:
#         paths = os.listdir(self.prefix_dir)
#         return tuple(path for path in paths if path.endswith(end))
# 
# Path: pre_commit/util.py
# @contextlib.contextmanager
# def clean_path_on_failure(path: str) -> Generator[None, None, None]:
#     """Cleans up the directory on an exceptional failure."""
#     try:
#         yield
#     except BaseException:
#         if os.path.exists(path):
#             rmtree(path)
#         raise


# Path: pre_commit/languages/perl.py
import contextlib
import os
import shlex
from typing import Generator
from typing import Sequence
from pre_commit.envcontext import envcontext
from pre_commit.envcontext import PatchesT
from pre_commit.envcontext import Var
from pre_commit.hook import Hook
from pre_commit.languages import helpers
from pre_commit.prefix import Prefix
from pre_commit.util import clean_path_on_failure

from __future__ import annotations



ENVIRONMENT_DIR = 'perl_env'
get_default_version = helpers.basic_get_default_version
healthy = helpers.basic_healthy


def _envdir(prefix: Prefix, version: str) -> str:
    directory = helpers.environment_dir(ENVIRONMENT_DIR, version)
    return prefix.path(directory)


def get_env_patch(venv: str) -> PatchesT:
    return (

        ('PATH', (os.path.join(venv, 'bin'), os.pathsep, Var('PATH'))),