-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (63 loc) · 2.73 KB
/
Makefile
File metadata and controls
77 lines (63 loc) · 2.73 KB
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
# Makefile
# Default target
default: static-analysis tests
all: clean static-analysis docs build tests
BOLD := $(shell tput bold)
GREEN := $(shell tput setaf 2)
RESET := $(shell tput sgr0)
RED := $(shell tput setaf 1)
export PYTHONPATH := $(PWD)/src:$(PYTHONPATH)
# Check if the virtual environment is activated and not the default Conda environment
check-venv:
@if [ -n "$$VIRTUAL_ENV" ]; then \
echo "$(BOLD)$(GREEN)>> Virtual environment is activated (venv) <<$(RESET)"; \
elif [ -n "$$CONDA_PREFIX" ] && [ "$$CONDA_PREFIX" != "$$(conda info --base)" ]; then \
echo "$(BOLD)$(GREEN)>> Conda environment is activated and not the default Conda environment <<$(RESET)"; \
elif [ -n "$$PYENV_VIRTUAL_ENV" ]; then \
echo "$(BOLD)$(GREEN)>> Virtual environment is activated (pyenv) <<$(RESET)"; \
elif [ -n "$$PIPENV_ACTIVE" ]; then \
echo "$(BOLD)$(GREEN)>> Virtual environment is activated (pipenv) <<$(RESET)"; \
else \
echo "$(BOLD)$(RED)>> Error: Virtual environment not activated. Please activate your virtual environment of choice. <<$(RESET)"; \
exit 1; \
fi
# Install dependencies from requirements.txt
install: check-venv requirements.txt
@echo "$(BOLD)$(GREEN)>> Installing dependencies <<$(RESET)"
pip install -r requirements.txt
# Run the main application
static-analysis: install
@echo "$(BOLD)$(GREEN)>>Running static analysis <<$(RESET)"
@echo "should use something like flake8"
build: install
@echo "$(BOLD)$(GREEN)>>Building the application <<$(RESET)"
python -m pip install --upgrade pip
pip install build
python -m build
build_wheel: install
@echo "$(BOLD)$(GREEN)>>Building only the wheel of the application <<$(RESET)"
python -m pip install --upgrade pip
pip install build
python -m build --wheel
freeze:
@echo "$(BOLD)$(GREEN)>>Freezing the dependencies <<$(RESET)"
pip freeze > requirements.txt
sed -i '/visualgo/d' requirements.txt
tests: install
@echo "$(BOLD)$(GREEN)>>Running tests <<$(RESET)"
python -m pytest --cov=src/visualgo --cov-report=html --cov-report=term-missing tests/
@echo "$(BOLD)$(GREEN)>> Coverage HTML report can be found in htmlcov/index.html <<$(RESET)"
tests_outputs: install
@echo "$(BOLD)$(GREEN)>>Running tests <<$(RESET)"
python -m pytest -s --cov=src/visualgo --cov-report=html --cov-report=term-missing tests/
@echo "$(BOLD)$(GREEN)>> Coverage HTML report can be found in htmlcov/index.html <<$(RESET)"
docs: install
sphinx-apidoc -o docs/ src/visualgo
sphinx-build -b html docs/ docs/_build
# Clean up the project
clean:
@echo "$(BOLD)$(GREEN)>>Cleaning up <<$(RESET)"
rm -rf build dist htmlcov .pytest_cache .coverage docs/_build
@echo "$(BOLD)$(GREEN)Project Visualgo-PyPI cleaned correctly.$(RESET)"
# Define phony targets
.PHONY: all check-venv install run clean tests freeze docs