Skip to content

Commit

Permalink
Remove circular import
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoesters committed Sep 20, 2024
1 parent 2edf320 commit 25b97b0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
3 changes: 2 additions & 1 deletion constructor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def main_build(dir_path, output_dir='.', platform=cc_platform,
if platform != cc_platform and 'pkg' in itypes and not cc_platform.startswith('osx-'):
sys.exit("Error: cannot construct a macOS 'pkg' installer on '%s'" % cc_platform)

exe_type, exe_version = identify_conda_exe(info.get["_conda_exe"])
exe_type, exe_version = identify_conda_exe(info.get("_conda_exe"))
exe_version = Version(exe_version)
info["_conda_exe_type"] = exe_type
info["_conda_exe_version"] = exe_version
if osname == "win" and exe_type == StandaloneExe.MAMBA:
Expand Down
8 changes: 3 additions & 5 deletions constructor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

from ruamel.yaml import YAML

from .conda_interface import VersionOrder as Version

logger = logging.getLogger(__name__)
yaml = YAML(typ="rt")
yaml.default_flow_style = False
Expand Down Expand Up @@ -259,19 +257,19 @@ def approx_size_kb(info, which="pkgs"):
return int(math.ceil(size_bytes/1000))


def identify_conda_exe(conda_exe=None) -> Tuple[StandaloneExe, Version]:
def identify_conda_exe(conda_exe=None) -> Tuple[StandaloneExe, str]:
if conda_exe is None:
conda_exe = normalize_path(join(sys.prefix, "standalone_conda", "conda.exe"))
try:
output_version = check_output([conda_exe, "--version"], text=True)
output_version = output_version.strip()
fields = output_version.split()
if "conda" in fields:
return StandaloneExe.CONDA, Version(fields[1])
return StandaloneExe.CONDA, fields[1]
# micromamba only returns the version number
output_help = check_output([conda_exe, "--help"], text=True)
if "Usage: micromamba" in output_help:
return StandaloneExe.MAMBA, Version(output_version)
return StandaloneExe.MAMBA, output_version
except CalledProcessError as exc:
logger.warning(f"Could not identify standalone binary {exc}.")
pass
Expand Down
1 change: 1 addition & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
ON_CI = os.environ.get("CI")
CONSTRUCTOR_CONDA_EXE = os.environ.get("CONSTRUCTOR_CONDA_EXE")
CONDA_EXE, CONDA_EXE_VERSION = identify_conda_exe(CONSTRUCTOR_CONDA_EXE)
CONDA_EXE_VERSION = Version(CONDA_EXE_VERSION)
CONSTRUCTOR_DEBUG = bool(os.environ.get("CONSTRUCTOR_DEBUG"))
if artifacts_path := os.environ.get("CONSTRUCTOR_EXAMPLES_KEEP_ARTIFACTS"):
KEEP_ARTIFACTS_PATH = Path(artifacts_path)
Expand Down

0 comments on commit 25b97b0

Please sign in to comment.