(conda_exec, tarball, info)
| 60 | |
| 61 | |
| 62 | def get_header(conda_exec, tarball, info): |
| 63 | name = info["name"] |
| 64 | |
| 65 | has_license = bool(info.get("license_file")) |
| 66 | variables = ns_platform(info["_platform"]) |
| 67 | variables["keep_pkgs"] = bool(info.get("keep_pkgs", False)) |
| 68 | variables["batch_mode"] = bool(info.get("batch_mode", False)) |
| 69 | variables["has_license"] = has_license |
| 70 | if variables["batch_mode"] and has_license: |
| 71 | raise Exception( |
| 72 | "It is not possible to use both the 'batch_mode' and 'license_file' options together." |
| 73 | ) |
| 74 | for key in "pre_install", "post_install", "pre_uninstall": |
| 75 | variables["has_%s" % key] = bool(key in info) |
| 76 | if key in info: |
| 77 | variables["direct_execute_%s" % key] = has_shebang(info[key]) |
| 78 | variables["initialize_conda"] = info.get("initialize_conda", "classic") |
| 79 | variables["initialize_by_default"] = info.get("initialize_by_default", False) |
| 80 | variables["has_conda"] = info["_has_conda"] |
| 81 | variables["enable_shortcuts"] = str(info["_enable_shortcuts"]).lower() |
| 82 | variables["check_path_spaces"] = info.get("check_path_spaces", True) |
| 83 | # Omit __osx and __glibc because those are tested with shell code directly |
| 84 | virtual_specs = [ |
| 85 | spec |
| 86 | for spec in info.get("virtual_specs", ()) |
| 87 | if "__osx" not in spec and "__glibc" not in spec |
| 88 | ] |
| 89 | variables["installer_name"] = name |
| 90 | variables["installer_version"] = info["version"] |
| 91 | variables["installer_platform"] = info["_platform"] |
| 92 | variables["installer_md5"] = hash_files([conda_exec, *info["_internal_conda_files"], tarball]) |
| 93 | variables["default_prefix"] = info.get("default_prefix", "${HOME:-/opt}/%s" % name.lower()) |
| 94 | variables["first_payload_size"] = getsize(conda_exec) |
| 95 | variables["second_payload_size"] = getsize(tarball) |
| 96 | variables["conda_exe_payloads"] = info.get("_conda_exe_payloads", {}) |
| 97 | variables["conda_exe_payloads_size"] = info.get("_conda_exe_payloads_size", 0) |
| 98 | variables["final_channels"] = get_final_channels(info) |
| 99 | variables["conclusion_text"] = info.get("conclusion_text", "installation finished.") |
| 100 | variables["pycache"] = "__pycache__" |
| 101 | variables["shortcuts"] = shortcuts_flags(info) |
| 102 | variables["register_envs"] = str(info.get("register_envs", True)).lower() |
| 103 | variables["total_installation_size_kb"] = str(approx_size_kb(info, "total")) |
| 104 | variables["virtual_specs"] = shlex.join(virtual_specs) |
| 105 | variables["no_rcs_arg"] = info.get("_ignore_condarcs_arg", "") |
| 106 | if has_license: |
| 107 | variables["license"] = read_ascii_only(info["license_file"]) |
| 108 | |
| 109 | virtual_specs = parse_virtual_specs(info) |
| 110 | min_osx_version = virtual_specs.get("__osx", {}).get("min") or "" |
| 111 | variables["min_osx_version"] = min_osx_version |
| 112 | variables["conda_exe_name"] = format_conda_exe_name(info["_conda_exe"]) |
| 113 | min_glibc_version = virtual_specs.get("__glibc", {}).get("min") or "" |
| 114 | variables["min_glibc_version"] = min_glibc_version |
| 115 | |
| 116 | variables["script_env_variables"] = info.get("script_env_variables", {}) |
| 117 | |
| 118 | return render_template(read_header_template(), **variables) |
| 119 |
no test coverage detected