-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
74 lines (70 loc) · 2.62 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
# Makefile for COSC525-Project2
.ONESHELL:
SHELL=/bin/bash
PYTHON_VERSION=3.10
ENV_NAME=tune_craft
# You can use either venv (venv) or conda env
# by specifying the correct argument (env=<conda, venv>)
ifeq ($(env),venv)
# Use Conda
BASE=venv
BIN=$(BASE)/bin
CREATE_COMMAND="python$(PYTHON_VERSION) -m venv $(BASE)"
DELETE_COMMAND="rm -rf $(BASE)"
ACTIVATE_COMMAND="source venv/bin/activate"
DEACTIVATE_COMMAND="deactivate"
else
# Use Conda
BASE=~/anaconda3/envs/$(ENV_NAME)
BIN=$(BASE)/bin
CREATE_COMMAND="conda create --prefix $(BASE) python=$(PYTHON_VERSION) -y"
DELETE_COMMAND="conda env remove -p $(BASE)"
ACTIVATE_COMMAND="conda activate -p $(BASE)"
DEACTIVATE_COMMAND="conda deactivate"
endif
# To load a env file use env_file=<path to env file>
# e.g. make release env_file=.env
ifneq ($(env_file),)
include $(env_file)
# export
endif
all:
$(MAKE) help
help:
@echo
@echo "-----------------------------------------------------------------------------------------------------------"
@echo " DISPLAYING HELP "
@echo "-----------------------------------------------------------------------------------------------------------"
@echo "Use make <make recipe> [env=<conda|venv>] [env_file=<path to env file>]"
@echo
@echo "make help"
@echo " Display this message"
@echo "make install [env=<conda|venv>] [env_file=<path to env file>]"
@echo " Call clean delete_conda_env create_conda_env setup tests"
@echo "make clean [env=<conda|venv>] [env_file=<path to env file>]"
@echo " Delete all './build ./dist ./*.pyc ./*.tgz ./*.egg-info' files"
@echo "make create_env [env=<conda|venv>] [env_file=<path to env file>]"
@echo " Create a new conda env or virtualenv for the specified python version"
@echo "make delete_env [env=<conda|venv>] [env_file=<path to env file>]"
@echo " Delete the current conda env or virtualenv"
@echo "-----------------------------------------------------------------------------------------------------------"
install:
$(MAKE) delete_env
$(MAKE) create_env
$(MAKE) clean
$(MAKE) requirements
@echo -e "\033[0;31m############################################"
@echo
@echo "Installation Successful!"
@echo "To activate the conda environment run:"
@echo ' conda activate $(ENV_NAME)'
requirements:
# conda install --file requirements.txt -y
pip install -r requirements.txt
create_env:
@echo "Creating virtual environment.."
@eval $(CREATE_COMMAND)
delete_env:
@echo "Deleting virtual environment.."
@eval $(DELETE_COMMAND)
.PHONY: help install clean delete_env create_env requirements