Skip to content

Commit 1355a97

Browse files
Merge pull request #55 from TUW-GEO/dev
store conda env in current dir
2 parents 4bd2402 + 597c647 commit 1355a97

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Diff for: Makefile

+12-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ QN != git diff --cached --name-only "***.ipynb"
1111
CONDA_ENV != conda info --base
1212
CONDA_ACTIVATE := source $(CONDA_ENV)/etc/profile.d/conda.sh ; \
1313
conda activate ; conda activate
14-
CONDA_ENV_DIR := $(foreach i,$(REQ),$(CONDA_ENV)/envs/$(i))
14+
PREFIX = $(CURDIR)/.conda_envs
15+
CONDA_ENV_DIR := $(foreach i,$(REQ),$(PREFIX)/$(i))
1516
KERNEL_DIR != $(CONDA_ACTIVATE) eo-datascience; jupyter --data-dir
1617
KERNEL_DIR := $(foreach i,$(REQ),$(KERNEL_DIR)/kernels/$(i))
1718

@@ -23,6 +24,7 @@ help:
2324
@echo " make kernel - Create Conda environments and Jupyter kernels"
2425
@echo " make post-render - Post-render Quarto book"
2526
@echo " make preview - Preview Jupyter Book"
27+
@echo " make convert - Convert Jupyter notebooks to Quarto notebooks"
2628
@echo " "
2729
@echo " make teardown - Remove Conda environments and Jupyter kernels"
2830
@echo " make clean - Removes ipynb_checkpoints and quarto \
@@ -34,16 +36,18 @@ $(CONDA_ENV)/envs/eo-datascience:
3436
conda env create --file environment.yml
3537

3638
$(CONDA_ENV_DIR):
37-
$(foreach f, $(YML), conda env create --file $(f); )
39+
$(foreach f, $(YML), \
40+
conda env create --file $(f) \
41+
--prefix $(PREFIX)/$(basename $(notdir $(f))); )
3842

3943
environment: $(CONDA_ENV_DIR)
4044
@echo -e "conda environments are ready."
4145

4246
$(KERNEL_DIR):
4347
$(foreach f, $(REQ), \
44-
$(CONDA_ACTIVATE) $(f); \
48+
$(CONDA_ACTIVATE) $(PREFIX)/$(f); \
4549
python -m ipykernel install --user --name $(f) --display-name $(f); \
46-
conda deactivate; )
50+
conda deactivate; )
4751

4852
kernel: $(CONDA_ENV)/envs/eo-datascience $(CONDA_ENV_DIR) $(KERNEL_DIR)
4953
@echo -e "jupyter kernels are ready."
@@ -60,7 +64,7 @@ convert:
6064
mv $(subst .ipynb,.qmd, $(f)) $(subst notebooks,chapters,$(subst .ipynb,.qmd,$(f))); )
6165

6266
preview: $(CONDA_ENV)/envs/eo-datascience $(CONDA_ENV_DIR) $(KERNEL_DIR)
63-
$(CONDA_ACTIVATE) eo-datascience
67+
$(CONDA_ACTIVATE) $(PREFIX)/eo-datascience
6468
- mkdir -p _preview/notebooks
6569
python -m pip install .
6670
cp ./chapters/references.bib ./_preview/notebooks/
@@ -79,10 +83,10 @@ clean:
7983
./**/**/.jupyter_cache
8084

8185
teardown:
82-
conda remove -n eo-datascience --all -y
86+
conda remove -n $(PREFIX)/eo-datascience --all -y
8387
$(foreach f, $(REQ), \
84-
$(CONDA_ACTIVATE) $(f); \
88+
$(CONDA_ACTIVATE) $(PREFIX)/$(f); \
8589
jupyter kernelspec uninstall -y $(f); \
8690
conda deactivate; \
87-
conda remove -n $(f) --all -y ; \
91+
conda remove --prefix $(PREFIX)/$(f) --all -y ; \
8892
conda deactivate; )

0 commit comments

Comments
 (0)