MCPcopy Create free account
hub / github.com/conda/constructor / create_installer

Function create_installer

tests/test_examples.py:614–677  ·  view source on GitHub ↗
(
    input_dir: Path,
    workspace: Path,
    conda_exe=CONSTRUCTOR_CONDA_EXE,
    debug=CONSTRUCTOR_DEBUG,
    with_spaces=False,
    timeout=420,
    config_filename="construct.yaml",
    extra_constructor_args: Iterable[str] = None,
    **env_vars,
)

Source from the content-addressed store, hash-verified

612
613
614def create_installer(
615 input_dir: Path,
616 workspace: Path,
617 conda_exe=CONSTRUCTOR_CONDA_EXE,
618 debug=CONSTRUCTOR_DEBUG,
619 with_spaces=False,
620 timeout=420,
621 config_filename="construct.yaml",
622 extra_constructor_args: Iterable[str] = None,
623 **env_vars,
624) -> Generator[tuple[Path, Path], None, None]:
625 if sys.platform.startswith("win") and conda_exe and _is_micromamba(conda_exe):
626 pytest.skip("Micromamba is not supported on Windows yet.")
627
628 output_dir = workspace / "installer"
629 output_dir.mkdir(parents=True, exist_ok=True)
630 cmd = [*COV_CMD, "constructor"]
631 # This flag will (if enabled) create a lot of output upon test failures for .exe-installers.
632 # If debugging generated NSIS templates, it can be worth to enable.
633 if CONSTRUCTOR_VERBOSE:
634 cmd.append("-v")
635 cmd += [
636 str(input_dir),
637 "--output-dir",
638 str(output_dir),
639 "--config-filename",
640 config_filename,
641 ]
642
643 if conda_exe:
644 cmd.extend(["--conda-exe", conda_exe])
645 if debug:
646 cmd.append("--debug")
647 if extra_constructor_args:
648 cmd.extend(extra_constructor_args)
649
650 _execute(cmd, timeout=timeout, **env_vars)
651
652 install_dir_prefix = "i n s t a l l" if with_spaces else "install"
653
654 def _sort_by_extension(path):
655 "Return shell installers first so they are run before the GUI ones"
656 return {"sh": 1, "pkg": 2, "exe": 3, "msi": 4}[path.suffix[1:]], path
657
658 installers = (p for p in output_dir.iterdir() if p.suffix in (".exe", ".msi", ".sh", ".pkg"))
659 for installer in sorted(installers, key=_sort_by_extension):
660 if installer.suffix == ".pkg" and ON_CI:
661 install_dir = Path("~").expanduser() / calculate_install_dir(
662 input_dir / config_filename
663 )
664 elif installer.suffix == ".msi":
665 install_dir = calculate_msi_install_path(input_dir / config_filename)
666 else:
667 install_dir = (
668 workspace / f"{install_dir_prefix}-{installer.stem}-{installer.suffix[1:]}"
669 )
670
671 yield installer, install_dir

Calls 4

calculate_install_dirFunction · 0.90
_is_micromambaFunction · 0.85
_executeFunction · 0.85

Tested by

no test coverage detected