-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
61 lines (52 loc) · 2.21 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
.PHONY: clean jupyter lint requirements venv
#################################################################################
# GLOBALS #
#################################################################################
PROJECT_NAME = evsim
PROJECT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
VENV_DIR = $(PROJECT_DIR)/env
JUPYTER_DIR = $(VENV_DIR)/share/jupyter
PYTHON_INTERPRETER = $(VENV_DIR)/bin/python3
PIP = $(VENV_DIR)/bin/pip
IPYTHON = $(VENV_DIR)/bin/ipython
JUPYTER = $(VENV_DIR)/bin/jupyter
NOTEBOOK_DIR = $(PROJECT_DIR)/notebooks
#################################################################################
# COMMANDS #
#################################################################################
## Install Python Dependencies
requirements: venv
$(PIP) install -e .
$(PIP) install -U pip setuptools wheel
$(PIP) install -r requirements.txt
## Delete all compiled Python files
clean:
find . -type f -name "*.py[co]" -delete
find . -type d -name "__pycache__" -delete
## Lint using flake8
lint:
@$(PYTHON_INTERPRETER) -m flake8 --config=$(PROJECT_DIR)/.flake8 src
# Launch jupyter server and create custom kernel if necessary
jupyter:
ifeq ($(wildcard $(JUPYTER_DIR)/kernels/$(PROJECT_NAME)/*),)
@echo "Creating custom kernel..."
@$(IPYTHON) kernel install --sys-prefix --name=$(PROJECT_NAME)
endif
ifeq ($(wildcard $(JUPYTER_DIR)/nbextensions/table_beautifier/*),)
@echo "Installing jupyter notebook extensions..."
@$(JUPYTER) contrib nbextension install --sys-prefix
@$(JUPYTER) nbextensions_configurator enable --sys-prefix
endif
ifeq ($(wildcard $(JUPYTER_DIR)/nbextensions/vim_binding/*),)
@echo "Installing vim binding extension..."
@git clone https://github.com/lambdalisue/jupyter-vim-binding $(JUPYTER_DIR)/nbextensions/vim_binding
endif
@echo "Running jupyter notebook in background..."
@JUPYTER_CONFIG_DIR=$(NOTEBOOK_DIR) $(JUPYTER) notebook --notebook-dir=$(NOTEBOOK_DIR)
## Install virtual environment
venv:
ifeq ($(wildcard $(VENV_DIR)/*),)
@echo "Did not find $(VENV_DIR), creating..."
mkdir -p $(VENV_DIR)
python -m venv $(VENV_DIR)
endif