-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
81 lines (73 loc) · 2.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
.DEFAULT_GOAL := help
########################################################################\
Make gitignore file
########################################################################
.PHONY: giti
giti: ## Make .gitignore from gitignore.io
@echo "==> $@"
rm -rf .gitignore
echo "venv*" > .gitignore
echo "Copy*.ipynb" >> .gitignore
echo "scratch/*" >> .gitignore
echo "*xlsx" >> .gitignore
echo "**/*.tar.gz" >> .gitignore
echo "**/*.csv*" >> .gitignore
echo "**/*.xls" >> .gitignore
echo "**/*.xlsx" >> .gitignore
curl https://www.toptal.com/developers/gitignore/api/python >> .gitignore
curl https://www.toptal.com/developers/gitignore/api/jupyternotebooks >> .gitignore
curl https://www.toptal.com/developers/gitignore/api/tex >> .gitignore
# ============================================================================
# Set up the Python virtual environment and prepare the Jupyter distribution
# Installs packages from requirements.txt
# ============================================================================
.PHONY: setup
VENVPATH ?= venv
ifeq ($(OS),Windows_NT)
VENVPATH := c:/users/admin/$(VENVPATH)
ACTIVATE_PATH := $(VENVPATH)/Scripts/activate
else
ACTIVATE_PATH := $(VENVPATH)/bin/activate
endif
REQUIREMENTS := requirements.txt
setup: ## Set up venv
setup: $(REQUIREMENTS)
@echo "==> $@"
@echo "==> Creating and initializing virtual environment..."
rm -rf $(VENVPATH)
python -m venv $(VENVPATH)
. $(ACTIVATE_PATH) && \
pip install --upgrade pip && \
which pip && \
pip list && \
echo "==> Installing requirements" && \
pip install -r $< && \
jupyter contrib nbextensions install --sys-prefix --skip-running-check && \
echo "==> Packages available:" && \
which pip && \
pip list && \
which jupyter && \
deactivate
@echo "==> Setup complete."
# ============================================================================
# Open Jupyter notebook in the venv
# ============================================================================
.PHONY: jn
jn: ## Launch jupyter notebook in venv
@echo "==> $@"
if [ -f $(VENVPATH)/Scripts/activate ]; then \
. $(VENVPATH)/Scripts/activate && jupyter notebook; \
elif [ -f $(VENVPATH)/bin/activate ]; then \
. $(VENVPATH)/bin/activate && jupyter notebook; \
else \
@echo "No venv found"; \
fi
########################################################################
# Other utilities
########################################################################
.PHONY: clean
clean: ## Clean all symlinks aux reports
clean: clean_sl clean_sl_task
.PHONY: help
help: ## Show this help message and exit
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-16s\033[0m %s\n", $$1, $$2}'