Prepare files on disk to be shipped as part of the pre-conda payload, mostly configuration and metadata files: - `conda-meta/initial-state.explicit.txt`: Lockfile to provision the base environment. - `conda-meta/history`: Prepared history file with the right requested specs in inpu
(info: dict, workspace: str)
| 143 | |
| 144 | |
| 145 | def write_files(info: dict, workspace: str): |
| 146 | """ |
| 147 | Prepare files on disk to be shipped as part of the pre-conda payload, mostly |
| 148 | configuration and metadata files: |
| 149 | |
| 150 | - `conda-meta/initial-state.explicit.txt`: Lockfile to provision the base environment. |
| 151 | - `conda-meta/history`: Prepared history file with the right requested specs in input file. |
| 152 | - `conda-meta/frozen`: Frozen marker file used to protect conda environment state. |
| 153 | - `pkgs/urls` and `pkgs/urls.txt`: Direct URLs of packages used, with and without MD5 hashes. |
| 154 | - `pkgs/cache/*.json`: Trimmed repodata to mock offline channels in use. |
| 155 | - `pkgs/channels.txt`: Channels in use. |
| 156 | - `pkgs/shortcuts.txt`: Which packages should have their shortcuts created, if any. |
| 157 | |
| 158 | If extra envs are requested, this will also write: |
| 159 | |
| 160 | - Their corresponding `envs/<env-name>/conda-meta/` files. |
| 161 | - Their corresponding `pkgs/channels.txt` and `pkgs/shortcuts.txt` under |
| 162 | `pkgs/envs/<env-name>`. |
| 163 | """ |
| 164 | os.makedirs(join(workspace, "conda-meta"), exist_ok=True) |
| 165 | pkgs_dir = join(workspace, "pkgs") |
| 166 | os.makedirs(pkgs_dir, exist_ok=True) |
| 167 | with open(join(pkgs_dir, ".constructor-build.info"), "w") as fo: |
| 168 | json.dump(system_info(), fo) |
| 169 | |
| 170 | out = { |
| 171 | "name": info.get("name"), |
| 172 | "version": info.get("version"), |
| 173 | "platform": info.get("_platform"), |
| 174 | "type": info.get("installer_type"), |
| 175 | } |
| 176 | with open(join(workspace, ".installer.info"), "w") as fo: |
| 177 | json.dump(out, fo) |
| 178 | |
| 179 | all_urls = info["_urls"].copy() |
| 180 | for env_info in info.get("_extra_envs_info", {}).values(): |
| 181 | all_urls += env_info["_urls"] |
| 182 | |
| 183 | final_urls_md5s = tuple((get_final_url(info, url), md5) for url, md5 in info["_urls"]) |
| 184 | all_final_urls_md5s = tuple((get_final_url(info, url), md5) for url, md5 in all_urls) |
| 185 | |
| 186 | with open(join(pkgs_dir, "urls"), "w") as fo: |
| 187 | for url, md5 in all_final_urls_md5s: |
| 188 | maybe_different_url = ensure_transmuted_ext(info, url) |
| 189 | if maybe_different_url != url: # transmuted, no md5 |
| 190 | fo.write(f"{maybe_different_url}\n") |
| 191 | else: |
| 192 | fo.write(f"{url}#{md5}\n") |
| 193 | |
| 194 | with open(join(pkgs_dir, "urls.txt"), "w") as fo: |
| 195 | for url, _ in all_final_urls_md5s: |
| 196 | fo.write("%s\n" % url) |
| 197 | |
| 198 | all_dists = info["_dists"].copy() |
| 199 | for env_info in info.get("_extra_envs_info", {}).values(): |
| 200 | all_dists += env_info["_dists"] |
| 201 | all_dists = list({dist: None for dist in all_dists}) # de-duplicate |
| 202 |
nothing calls this directly
no test coverage detected