mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-21 13:50:20 +08:00
Merge pull request #14770 from johanneskoester/feat/mulled-mamba-support
feat: mamba support for mulled-build
This commit is contained in:
@@ -42,9 +42,10 @@ end
|
||||
|
||||
local conda_image = VAR.CONDA_IMAGE
|
||||
if conda_image == '' then
|
||||
conda_image = 'continuumio/miniconda3:latest'
|
||||
conda_image = 'quay.io/condaforge/mambaforge:latest'
|
||||
end
|
||||
|
||||
local conda_bin = VAR.CONDA_BIN
|
||||
|
||||
local singularity_image = VAR.SINGULARITY_IMAGE
|
||||
if singularity_image == '' then
|
||||
@@ -87,7 +88,7 @@ inv.task('build')
|
||||
.using(conda_image)
|
||||
.withHostConfig({binds = bind_args})
|
||||
.run('/bin/sh', '-c', preinstall
|
||||
.. 'conda install '
|
||||
.. conda_bin .. ' install '
|
||||
.. channel_args .. ' '
|
||||
.. target_args
|
||||
.. ' --strict-channel-priority -p /usr/local --copy --yes '
|
||||
|
||||
@@ -197,6 +197,8 @@ def mull_targets(
|
||||
repository_template=DEFAULT_REPOSITORY_TEMPLATE,
|
||||
dry_run=False,
|
||||
conda_version=None,
|
||||
mamba_version=None,
|
||||
use_mamba=False,
|
||||
verbose=False,
|
||||
binds=DEFAULT_BINDS,
|
||||
rebuild=True,
|
||||
@@ -284,9 +286,28 @@ def mull_targets(
|
||||
involucro_args.extend(["-set", f"USER_ID={os.getuid()}:{os.getgid()}"])
|
||||
if test:
|
||||
involucro_args.extend(["-set", f"TEST={test}"])
|
||||
if conda_version is not None:
|
||||
verbose = "--verbose" if verbose else "--quiet"
|
||||
involucro_args.extend(["-set", f"PREINSTALL=conda install {verbose} --yes conda={conda_version}"])
|
||||
|
||||
verbose = "--verbose" if verbose else "--quiet"
|
||||
conda_bin = "conda"
|
||||
if use_mamba:
|
||||
conda_bin = "mamba"
|
||||
if mamba_version is None:
|
||||
mamba_version = ""
|
||||
involucro_args.extend(["-set", "CONDA_BIN=%s" % conda_bin])
|
||||
if conda_version is not None or mamba_version is not None:
|
||||
mamba_test = "true"
|
||||
specs = []
|
||||
if conda_version is not None:
|
||||
specs.append(f"conda={conda_version}")
|
||||
if mamba_version is not None:
|
||||
specs.append(f"mamba={mamba_version}")
|
||||
if mamba_version == "" and not specs:
|
||||
# If nothing but mamba without a specific version is requested,
|
||||
# then only run conda install if mamba is not already installed.
|
||||
mamba_test = "[ '[]' = \"$( conda list --json --full-name mamba )\" ]"
|
||||
conda_install = f"""conda install {verbose} --yes {" ".join(f"'{spec}'" for spec in specs)}"""
|
||||
involucro_args.extend(["-set", f"PREINSTALL=if {mamba_test} ; then {conda_install} ; fi"])
|
||||
|
||||
involucro_args.append(command)
|
||||
if test_files:
|
||||
test_bind = []
|
||||
@@ -456,6 +477,18 @@ def add_build_arguments(parser):
|
||||
default=None,
|
||||
help="Change to specified version of Conda before installing packages.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--mamba-version",
|
||||
dest="mamba_version",
|
||||
default=None,
|
||||
help="Change to specified version of Mamba before installing packages.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--use-mamba",
|
||||
dest="use_mamba",
|
||||
action="store_true",
|
||||
help="Use Mamba instead of Conda for package installation.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--oauth-token",
|
||||
dest="oauth_token",
|
||||
@@ -521,6 +554,10 @@ def args_to_mull_targets_kwds(args):
|
||||
kwds["repository_template"] = args.repository_template
|
||||
if hasattr(args, "conda_version"):
|
||||
kwds["conda_version"] = args.conda_version
|
||||
if hasattr(args, "mamba_version"):
|
||||
kwds["mamba_version"] = args.mamba_version
|
||||
if hasattr(args, "use_mamba"):
|
||||
kwds["use_mamba"] = args.use_mamba
|
||||
if hasattr(args, "oauth_token"):
|
||||
kwds["oauth_token"] = args.oauth_token
|
||||
if hasattr(args, "rebuild"):
|
||||
|
||||
@@ -27,11 +27,18 @@ def test_base_image_for_targets(target, version, base_image):
|
||||
assert base_image_for_targets([target], conda_context) == base_image
|
||||
|
||||
|
||||
@pytest.mark.parametrize("use_mamba", [False, True])
|
||||
@external_dependency_management
|
||||
def test_mulled_build_files_cli(tmpdir):
|
||||
def test_mulled_build_files_cli(use_mamba, tmpdir):
|
||||
singularity_image_dir = tmpdir.mkdir("singularity image dir")
|
||||
target = build_target("zlib")
|
||||
mull_targets([target], command="build-and-test", singularity=True, singularity_image_dir=singularity_image_dir)
|
||||
mull_targets(
|
||||
[target],
|
||||
command="build-and-test",
|
||||
singularity=True,
|
||||
use_mamba=use_mamba,
|
||||
singularity_image_dir=singularity_image_dir,
|
||||
)
|
||||
assert singularity_image_dir.join("zlib").exists()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user