Skip to content

Commit

Permalink
Merge pull request #721 from nkaretnikov/env-vars-719
Browse files Browse the repository at this point in the history
Pass `CONDA_OVERRIDE_CUDA` to `with_cuda` of conda-lock
  • Loading branch information
Nikita Karetnikov authored Jan 16, 2024
2 parents 03191b4 + 8c9390c commit f63b4d7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 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,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"
Expand All @@ -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)
Expand Down

0 comments on commit f63b4d7

Please sign in to comment.