(
prefix: Prefix,
version: str,
additional_dependencies: Sequence[str],
)
| 62 | |
| 63 | |
| 64 | def install_environment( |
| 65 | prefix: Prefix, |
| 66 | version: str, |
| 67 | additional_dependencies: Sequence[str], |
| 68 | ) -> None: |
| 69 | envdir = lang_base.environment_dir(prefix, ENVIRONMENT_DIR, version) |
| 70 | with in_env(prefix, version): |
| 71 | # TODO: Support language_version with juliaup similar to rust via |
| 72 | # rustup |
| 73 | # if version != 'system': |
| 74 | # ... |
| 75 | |
| 76 | # Copy Project.toml to hook env if it exist |
| 77 | os.makedirs(envdir, exist_ok=True) |
| 78 | project_names = ('JuliaProject.toml', 'Project.toml') |
| 79 | project_found = False |
| 80 | for project_name in project_names: |
| 81 | project_file = prefix.path(project_name) |
| 82 | if not os.path.isfile(project_file): |
| 83 | continue |
| 84 | shutil.copy(project_file, envdir) |
| 85 | project_found = True |
| 86 | break |
| 87 | |
| 88 | # If no project file was found we create an empty one so that the |
| 89 | # package manager doesn't error |
| 90 | if not project_found: |
| 91 | open(os.path.join(envdir, 'Project.toml'), 'a').close() |
| 92 | |
| 93 | # Copy Manifest.toml to hook env if it exists |
| 94 | manifest_names = ('JuliaManifest.toml', 'Manifest.toml') |
| 95 | for manifest_name in manifest_names: |
| 96 | manifest_file = prefix.path(manifest_name) |
| 97 | if not os.path.isfile(manifest_file): |
| 98 | continue |
| 99 | shutil.copy(manifest_file, envdir) |
| 100 | break |
| 101 | |
| 102 | # Julia code to instantiate the hook environment |
| 103 | julia_code = """ |
| 104 | @assert length(ARGS) > 0 |
| 105 | hook_env = ARGS[1] |
| 106 | deps = join(ARGS[2:end], " ") |
| 107 | |
| 108 | # We prepend @stdlib here so that we can load the package manager even |
| 109 | # though `get_env_patch` limits `JULIA_LOAD_PATH` to just the hook env. |
| 110 | pushfirst!(LOAD_PATH, "@stdlib") |
| 111 | using Pkg |
| 112 | popfirst!(LOAD_PATH) |
| 113 | |
| 114 | # Instantiate the environment shipped with the hook repo. If we have |
| 115 | # additional dependencies we disable precompilation in this step to |
| 116 | # avoid double work. |
| 117 | precompile = isempty(deps) ? "1" : "0" |
| 118 | withenv("JULIA_PKG_PRECOMPILE_AUTO" => precompile) do |
| 119 | Pkg.instantiate() |
| 120 | end |
| 121 |
nothing calls this directly
no test coverage detected