Skip to content

Commit 0ed5061

Browse files
authored
Merge pull request #86 from dssimmons-codes/add-micromamba
Support micromamba in conda Make targets
2 parents c829788 + 4c3add4 commit 0ed5061

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

Makefile

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,24 +248,32 @@ help:
248248
@echo " rebuild Full clean + build"
249249
@echo " format Run clang-format (if installed)"
250250
@echo " lint Run clang-tidy (if installed)"
251+
@echo " conda-setup Create/update env with conda or micromamba"
252+
@echo " mamba-setup Create/update env with micromamba/mamba"
251253
@echo
252254
@echo "Examples:"
253255
@echo " make MODE=debug"
254256
@echo " make MODE=release OMP=0"
255257

256-
# --- Conda helpers (do not require 'conda activate') -------------------------
257-
CONDA ?= conda
258+
# --- Conda/micromamba helpers (do not require 'conda activate') --------------
259+
CONDA ?= $(shell command -v conda 2>/dev/null || command -v micromamba 2>/dev/null || command -v mamba 2>/dev/null || printf conda)
260+
MAMBA ?= $(shell command -v micromamba 2>/dev/null || command -v mamba 2>/dev/null || printf micromamba)
261+
CONDA_TOOL := $(notdir $(CONDA))
258262
ENV_NAME ?= amdat
259263
# Prefer an exact lock if present, else fall back to environment.yml
260264
ENV_SPEC ?= $(if $(wildcard conda-linux-64.txt),conda-linux-64.txt,environment.yml)
261265
ENV_STAMP := .env/conda.ready
262266

263-
# Create/update the Conda environment
264-
.PHONY: conda-setup
267+
# Create/update the Conda-compatible environment
268+
.PHONY: conda-setup mamba-setup micromamba-setup
265269
conda-setup: $(ENV_STAMP)
266270

271+
mamba-setup micromamba-setup: CONDA = $(MAMBA)
272+
mamba-setup micromamba-setup: CONDA_TOOL = $(notdir $(MAMBA))
273+
mamba-setup micromamba-setup: $(ENV_STAMP)
274+
267275
$(ENV_STAMP):
268-
@echo ">> Creating conda env '$(ENV_NAME)' from $(ENV_SPEC)"
276+
@echo ">> Creating $(CONDA_TOOL) env '$(ENV_NAME)' from $(ENV_SPEC)"
269277
@mkdir -p .env
270278
@if [ "$(ENV_SPEC)" = "conda-linux-64.txt" ]; then \
271279
$(CONDA) create -y -n $(ENV_NAME) --file $(ENV_SPEC); \
@@ -282,7 +290,7 @@ $(ENV_STAMP):
282290
conda: $(ENV_STAMP)
283291
@$(CONDA) run -n $(ENV_NAME) bash -lc '\
284292
set -euo pipefail; \
285-
: "$${CONDA_PREFIX:?conda run did not set CONDA_PREFIX}"; \
293+
: "$${CONDA_PREFIX:?environment run did not set CONDA_PREFIX}"; \
286294
export PKG_CONFIG_PATH="$$CONDA_PREFIX/lib/pkgconfig:$${PKG_CONFIG_PATH:-}"; \
287295
# Prefer conda-forge triplet compilers if available; otherwise keep Makefile defaults \
288296
if command -v x86_64-conda-linux-gnu-g++ >/dev/null 2>&1; then \
@@ -294,7 +302,7 @@ conda: $(ENV_STAMP)
294302
echo ">> Using $$MAKE_CC $$MAKE_CXX"; \
295303
export CPATH="$$CONDA_PREFIX/include:$${CPATH:-}"; \
296304
export LIBRARY_PATH="$$CONDA_PREFIX/lib:$${LIBRARY_PATH:-}"; \
297-
echo ">> pkg-config: $(which pkg-config || true)"; \
305+
echo ">> pkg-config: $$(command -v pkg-config || true)"; \
298306
echo ">> fftw cflags: $$(pkg-config --cflags fftw3 || true)"; \
299307
echo ">> fftw libs: $$(pkg-config --libs fftw3 || true)"; \
300308
$(MAKE) $$MAKE_CC $$MAKE_CXX MODE=$(MODE) OMP=$(OMP) FFTW_ROOT="$$CONDA_PREFIX" \

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ conda activate amdat
4747
make
4848
```
4949

50+
This also works with other environment managers like micromamba and mamba.
51+
5052
### Run
5153
```bash
5254
./AMDAT -i path/to/input.in

0 commit comments

Comments
 (0)