Skip to content

Commit

Permalink
Pass CONDA_OVERRIDE_CUDA to with_cuda of conda-lock
Browse files Browse the repository at this point in the history
Fixes #719.
  • Loading branch information
nkaretnikov committed Jan 5, 2024
1 parent ec60664 commit 08db9db
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions conda-store-server/conda_store_server/action/generate_lockfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down

0 comments on commit 08db9db

Please sign in to comment.