-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
78 lines (60 loc) · 2.14 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
# --------------------------------------------------------------- utils
.PHONY: fmt # format and remove unused imports
fmt:
pip install isort
isort .
pip install autoflake
autoflake --remove-all-unused-imports --recursive --in-place .
pip install ruff
ruff format --config line-length=500 .
.PHONY: sec # check for common vulnerabilities
sec:
pip install bandit
pip install safety
bandit -r .
safety check --full-report
.PHONY: reqs # generate requirements.txt file
reqs:
pip install pipreqs
rm -rf requirements.txt
pipreqs .
.PHONY: up # pull remote changes and push local changes
up:
git pull
git add .
git commit -m "up"
git push
# --------------------------------------------------------------- conda
# workaround because makefile executes each line of the recipe in a separate sub-shell
.ONESHELL:
SHELL = /bin/bash
CONDA_DEACTIVATE = source $$(conda info --base)/etc/profile.d/conda.sh ; conda deactivate
CONDA_ACTIVATE_BASE = source $$(conda info --base)/etc/profile.d/conda.sh ; conda activate base
CONDA_ACTIVATE_CON = source $$(conda info --base)/etc/profile.d/conda.sh ; conda activate con
.PHONY: conda-snapshot # generate conda yaml file
conda-snapshot:
# conda config --env --set subdir osx-64
# conda config --env --set subdir osx-arm64
conda config --set auto_activate_base false
conda info
$(CONDA_ACTIVATE_BASE)
conda create --yes --name con python=3.11 anaconda
$(CONDA_ACTIVATE_CON)
pip install -r requirements.txt
conda env export --name con > conda-environment.yml
$(CONDA_DEACTIVATE)
conda remove --yes --name con --all
.PHONY: conda-install # install conda environment from yaml file
conda-install:
$(CONDA_ACTIVATE_BASE)
conda env create --file conda-environment.yml
@echo "to activate the conda environment, run: 'conda activate con'"
@echo "to deactivate the conda environment, run: 'conda deactivate'"
.PHONY: conda-clean # remove conda environment
conda-clean:
conda remove --yes --name con --all
conda env list
# --------------------------------------------------------------- help
.PHONY: help # generate help message
help:
@grep '^.PHONY: .* #' Makefile | sed 's/\.PHONY: \(.*\) # \(.*\)/\1 \2/' | expand -t20