-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
55 lines (46 loc) · 1.7 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
.ONESHELL:
SHELL = /bin/bash
.PHONY: help clean environment kernel teardown
YML = mrs-env.yml
REQ = $(basename $(notdir $(YML)))
BASENAME = $(CURDIR)
CONDA_ACTIVATE = source $$(conda info --base)/etc/profile.d/conda.sh ; conda activate ; conda activate
PREFIX = $(BASENAME)/.conda_envs
CONDA_ENV_DIR := $(foreach i,$(REQ),$(PREFIX)/$(i))
KERNEL_DIR := $(foreach i,$(REQ),$(shell jupyter --data-dir)/kernels/$(i))
help:
@echo "Makefile for setting up environment, kernel, and pulling notebooks"
@echo ""
@echo "Usage:"
@echo " make environment - Create Conda environments"
@echo " make kernel - Create Conda environments and Jupyter kernels"
@echo " "
@echo " make teardown - Remove Conda environments and Jupyter kernels"
@echo " make clean - Removes ipynb_checkpoints"
@echo " make help - Display this help message"
clean:
rm --force --recursive .ipynb_checkpoints/ **/.ipynb_checkpoints/ _book/ \
_freeze/ .quarto/
teardown:
$(foreach f, $(REQ), \
$(CONDA_ACTIVATE) $(f); \
jupyter kernelspec uninstall -y $(f); \
conda deactivate; \
conda remove -n $(f) --all -y ; \
conda deactivate; )
- conda config --remove envs_dirs $(PREFIX)
$(CONDA_ENV_DIR): $(YML)
- conda config --prepend envs_dirs $(PREFIX)
- conda update -n base -c conda-forge conda -y
$(foreach f, $^, \
conda env create --file $(f) \
--prefix $(PREFIX)/$(basename $(notdir $(f))); )
environment: $(CONDA_ENV_DIR)
@echo -e "conda environments are ready."
$(KERNEL_DIR): $(CONDA_ENV_DIR)
$(foreach f, $(REQ), \
$(CONDA_ACTIVATE) $(f); \
python -m ipykernel install --user --name $(f) --display-name $(f); \
conda deactivate; )
kernel: $(KERNEL_DIR)
@echo -e "conda jupyter kernel is ready."