(
dir_path: str,
output_dir: str = ".",
platform: str = cc_platform,
verbose: bool = True,
cache_dir: str = DEFAULT_CACHE_DIR,
dry_run: bool = False,
conda_exe: str = "conda.exe",
config_filename: str = "construct.yaml",
debug: bool = False,
)
| 202 | |
| 203 | |
| 204 | def main_build( |
| 205 | dir_path: str, |
| 206 | output_dir: str = ".", |
| 207 | platform: str = cc_platform, |
| 208 | verbose: bool = True, |
| 209 | cache_dir: str = DEFAULT_CACHE_DIR, |
| 210 | dry_run: bool = False, |
| 211 | conda_exe: str = "conda.exe", |
| 212 | config_filename: str = "construct.yaml", |
| 213 | debug: bool = False, |
| 214 | ): |
| 215 | logger.info("platform: %s", platform) |
| 216 | if not os.path.isfile(conda_exe): |
| 217 | sys.exit("Error: Conda executable '%s' does not exist!" % conda_exe) |
| 218 | cache_dir = abspath(expanduser(cache_dir)) |
| 219 | try: |
| 220 | osname, unused_arch = platform.split("-") |
| 221 | except ValueError: |
| 222 | sys.exit("Error: invalid platform string '%s'" % platform) |
| 223 | |
| 224 | construct_path = join(dir_path, config_filename) |
| 225 | info = construct_parse(construct_path, platform) |
| 226 | construct_verify(info) |
| 227 | info["CONSTRUCTOR_VERSION"] = __version__ |
| 228 | info["_input_dir"] = dir_path |
| 229 | info["_output_dir"] = output_dir |
| 230 | info["_platform"] = platform |
| 231 | info["_download_dir"] = join(cache_dir, platform) |
| 232 | info["_conda_exe"] = abspath(conda_exe) |
| 233 | info["_debug"] = debug |
| 234 | itypes = get_installer_type(info) |
| 235 | |
| 236 | if "docker" in itypes: |
| 237 | if not info.get("docker_base_image"): |
| 238 | sys.exit( |
| 239 | "Error: docker_base_image is required when building Docker artifacts. " |
| 240 | "Please specify a base image using the 'docker_base_image' key in construct.yaml." |
| 241 | ) |
| 242 | if info.get("docker_image_format") and not has_docker_buildx(): |
| 243 | sys.exit( |
| 244 | "Error: Building a Docker image requires Docker Buildx to be installed and available in PATH. " |
| 245 | "Install Docker Buildx to proceed, or remove `docker_image_format` to " |
| 246 | "generate the Dockerfile without building the portable image." |
| 247 | ) |
| 248 | |
| 249 | if platform != cc_platform and "pkg" in itypes and not cc_platform.startswith("osx-"): |
| 250 | sys.exit("Error: cannot construct a macOS 'pkg' installer on '%s'" % cc_platform) |
| 251 | |
| 252 | exe_type, exe_version = identify_conda_exe(info.get("_conda_exe")) |
| 253 | if exe_version is not None: |
| 254 | exe_version = Version(exe_version) |
| 255 | info["_conda_exe_type"] = exe_type |
| 256 | info["_conda_exe_version"] = exe_version |
| 257 | if osname == "win" and exe_type == StandaloneExe.MAMBA: |
| 258 | # TODO: Investigate errors on Windows and re-enable |
| 259 | sys.exit("Error: micromamba is not supported on Windows installers.") |
| 260 | |
| 261 | if info.get("uninstall_with_conda_exe") and not ( |
no test coverage detected