MCPcopy Index your code
hub / github.com/pre-commit/pre-commit / install_environment

Function install_environment

pre_commit/languages/coursier.py:23–62  ·  view source on GitHub ↗
(
        prefix: Prefix,
        version: str,
        additional_dependencies: Sequence[str],
)

Source from the content-addressed store, hash-verified

21
22
23def install_environment(
24 prefix: Prefix,
25 version: str,
26 additional_dependencies: Sequence[str],
27) -> None:
28 lang_base.assert_version_default('coursier', version)
29
30 # Support both possible executable names (either "cs" or "coursier")
31 cs = find_executable('cs') or find_executable('coursier')
32 if cs is None:
33 raise AssertionError(
34 'pre-commit requires system-installed "cs" or "coursier" '
35 'executables in the application search path',
36 )
37
38 envdir = lang_base.environment_dir(prefix, ENVIRONMENT_DIR, version)
39
40 def _install(*opts: str) -> None:
41 assert cs is not None
42 lang_base.setup_cmd(prefix, (cs, 'fetch', *opts))
43 lang_base.setup_cmd(prefix, (cs, 'install', '--dir', envdir, *opts))
44
45 with in_env(prefix, version):
46 channel = prefix.path('.pre-commit-channel')
47 if os.path.isdir(channel):
48 for app_descriptor in os.listdir(channel):
49 _, app_file = os.path.split(app_descriptor)
50 app, _ = os.path.splitext(app_file)
51 _install(
52 '--default-channels=false',
53 '--channel', channel,
54 app,
55 )
56 elif not additional_dependencies:
57 raise FatalError(
58 'expected .pre-commit-channel dir or additional_dependencies',
59 )
60
61 if additional_dependencies:
62 _install(*additional_dependencies)
63
64
65def get_env_patch(target_dir: str) -> PatchesT:

Callers

nothing calls this directly

Calls 5

find_executableFunction · 0.90
FatalErrorClass · 0.90
_installFunction · 0.85
pathMethod · 0.80
in_envFunction · 0.70

Tested by

no test coverage detected