From b3742de12a63b1393154fb2f2b1f34cf73531564 Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov Date: Fri, 5 Jan 2024 05:14:01 +0100 Subject: [PATCH 1/2] 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) From 8c9390c2c538cafd68b6080f9368e1b5af12d5e1 Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov Date: Tue, 16 Jan 2024 21:48:16 +0100 Subject: [PATCH 2/2] Add a TODO comment --- .../conda_store_server/action/generate_lockfile.py | 2 ++ 1 file changed, 2 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 f818816aa..caf2d9118 100644 --- a/conda-store-server/conda_store_server/action/generate_lockfile.py +++ b/conda-store-server/conda_store_server/action/generate_lockfile.py @@ -42,6 +42,8 @@ def print_cmd(cmd): # 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: