Skip to content

Commit

Permalink
Merge pull request #84 from mariusvniekerk/CONDA_FLAGS
Browse files Browse the repository at this point in the history
Add env variable CONDA_FLAGS to pass additional flags to conda/mamba
  • Loading branch information
mariusvniekerk authored Mar 16, 2021
2 parents f73c8b5 + 023a1e4 commit 2aa2050
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v3.4.0
hooks:
- id: trailing-whitespace
- id: check-ast

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
hooks:
- id: flake8
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8

- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.4.2
- repo: https://github.com/pycqa/isort
rev: 5.7.0
hooks:
- id: isort
args: [--multi-line=3, --trailing-comma, --force-grid-wrap=0, --use-parentheses, --line-width=88]
args: ["--profile", "black", "--filter-files"]

- repo: https://github.com/psf/black
rev: 20.8b1
Expand All @@ -23,6 +23,6 @@ repos:
language_version: python3

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.782
rev: v0.812
hooks:
- id: mypy
7 changes: 7 additions & 0 deletions conda_lock/conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import os
import pathlib
import re
import shlex
import shutil
import subprocess
import sys
Expand Down Expand Up @@ -94,6 +95,9 @@ def solve_specs_for_arch(
"--dry-run",
"--json",
]
conda_flags = os.environ.get("CONDA_FLAGS")
if conda_flags:
args.extend(shlex.split(conda_flags))
if channels:
args.append("--override-channels")
for channel in channels:
Expand Down Expand Up @@ -164,6 +168,9 @@ def do_conda_install(conda: PathLike, prefix: str, name: str, file: str) -> None
if name:
args.append("--name")
args.append(name)
conda_flags = os.environ.get("CONDA_FLAGS")
if conda_flags:
args.extend(shlex.split(conda_flags))

logging.debug("$MAMBA_ROOT_PREFIX: %s", os.environ.get("MAMBA_ROOT_PREFIX"))
proc = subprocess.run(
Expand Down
8 changes: 7 additions & 1 deletion tests/test_conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
conda_env_override,
create_lockfile_from_spec,
determine_conda_executable,
is_micromamba,
main,
parse_meta_yaml_file,
run_lock,
Expand Down Expand Up @@ -135,6 +136,8 @@ def test_parse_flit(flit_pyproject_toml, include_dev_dependencies):

def test_run_lock(monkeypatch, zlib_environment, conda_exe):
monkeypatch.chdir(zlib_environment.parent)
if is_micromamba(conda_exe):
monkeypatch.setenv("CONDA_FLAGS", "-v")
run_lock([zlib_environment], conda_exe=conda_exe)


Expand Down Expand Up @@ -233,7 +236,10 @@ def _check_package_installed(package: str, prefix: str):
return True


def test_install(tmp_path, conda_exe, zlib_environment):
def test_install(tmp_path, conda_exe, zlib_environment, monkeypatch):
if is_micromamba(conda_exe):
monkeypatch.setenv("CONDA_FLAGS", "-v")

package = "zlib"
platform = "linux-64"

Expand Down

0 comments on commit 2aa2050

Please sign in to comment.