From 08db9dbba33271b9b8f21cab3a9dac78d2fa2d46 Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov Date: Fri, 5 Jan 2024 05:14:01 +0100 Subject: [PATCH] Pass `CONDA_OVERRIDE_CUDA` to `with_cuda` of conda-lock Fixes #719. --- .../conda_store_server/action/generate_lockfile.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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..f818816aa 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,16 @@ 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 + 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 +58,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)