diff --git a/conda-store-server/conda_store_server/action/generate_lockfile.py b/conda-store-server/conda_store_server/action/generate_lockfile.py index 2fa2c327a..caf2d9118 100644 --- a/conda-store-server/conda_store_server/action/generate_lockfile.py +++ b/conda-store-server/conda_store_server/action/generate_lockfile.py @@ -37,6 +37,18 @@ def print_cmd(cmd): print_cmd(["conda", "config", "--show"]) print_cmd(["conda", "config", "--show-sources"]) + # conda-lock ignores variables defined in the specification, so this code + # gets the value of CONDA_OVERRIDE_CUDA and passes it to conda-lock via + # the with_cuda parameter, see: + # https://github.com/conda-incubator/conda-store/issues/719 + # https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-virtual.html#overriding-detected-packages + # TODO: Support all variables once upstream fixes are made to conda-lock, + # see the discussion in issue 719. + if specification.variables is not None: + cuda_version = specification.variables.get("CONDA_OVERRIDE_CUDA") + else: + cuda_version = None + # CONDA_FLAGS is used by conda-lock in conda_solver.solve_specs_for_arch try: conda_flags_name = "CONDA_FLAGS" @@ -48,6 +60,7 @@ def print_cmd(cmd): platforms=platforms, lockfile_path=lockfile_filename, conda_exe=conda_command, + with_cuda=cuda_version, ) finally: os.environ.pop(conda_flags_name, None)