forked from TUW-GEO/microwave-remote-sensing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
51 lines (42 loc) · 1.58 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
.ONESHELL:
SHELL = /bin/bash
.PHONY: help clean environment kernel teardown
YML = $(wildcard **/*.yml)
REQ = $(basename $(notdir $(YML)))
BASENAME = $(shell basename $(CURDIR))
CONDA_ACTIVATE = source $$(conda info --base)/etc/profile.d/conda.sh ; conda activate ; conda activate
PREFIX = ${HOME}/$(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/
teardown:
$(foreach f, $(REQ), \
jupyter kernelspec uninstall -y $(f); \
conda remove -n $(f) --all -y ; \
conda deactivate; )
- conda config --remove envs_dirs $(PREFIX)
$(CONDA_ENV_DIR): $(YML)
- conda config --prepend envs_dirs $(PREFIX)
$(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."