-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
72 lines (57 loc) · 2.36 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
SHELL := /bin/bash
REPO := https://github.com/sr-murthy/continuedfractions
PACKAGE_NAME := continuedfractions
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
HEAD := $(shell git rev-parse --short=8 HEAD)
PACKAGE_VERSION := $(shell grep __version__ src/continuedfractions/version.py | cut -d '=' -f 2 | xargs)
ROOT := $(PWD)
TESTS_ROOT := $(ROOT)/tests
DOCS_ROOT := $(PROJECT_ROOT)/docs
DOCS_BUILD := $(DOCS_ROOT)/_build
DOCS_BUILD_HTML := $(DOCS_ROOT)/_build/html
# Make everything (possible)
all:
# Git
git_stage:
@echo "\n$(PACKAGE_NAME)[$(BRANCH)@$(HEAD)]: Staging new, modified, deleted and/or renamed files in Git\n"
git status -uno | grep modified | tr -s ' ' | cut -d ' ' -f 2 | xargs git add && \
git status -uno | grep deleted | tr -s ' ' | cut -d ' ' -f 2 | xargs git add -A && \
git status -uno
# Housekeeping
clean:
@echo "\n$(PACKAGE_NAME)[$(BRANCH)@$(HEAD)]: Deleting all temporary files\n"
rm -fr docs/_build/* .pytest_cache *.pyc *__pycache__* ./dist/* ./build/* *.egg-info*
# A simple version check for the installed package (local, sdist or wheel)
version_check:
@echo "\n$(PACKAGE_NAME)[$(BRANCH)@$(HEAD)]: Checking installed package version (if it is installed)\n"
python3 -c "import os; os.chdir('src'); from version import __version__; print(__version__); os.chdir('../')"
version_extract:
echo "$(PACKAGE_VERSION)"
# Dependency management
update_deps:
@echo "\n$(PACKAGE_NAME)[$(BRANCH)@$(HEAD)]: Update all development dependencies, including documentation and production dependencies\n"
pdm update -v --dev --no-editable --no-self --update-all && pdm export -v -f requirements --dev -o docs/requirements.txt
# Linting
lint: clean
@echo "\n$(PACKAGE_NAME)[$(BRANCH)@$(HEAD)]: Linting source code with Ruff\n"
cd "$(PROJECT_ROOT)" && ruff check src
# Running tests
doctests: clean
@echo "\n$(PACKAGE_NAME)[$(BRANCH)@$(HEAD)]: Running doctests in all core libraries\n"
cd "$(PROJECT_ROOT)" && \
python3 -m doctest --verbose src/continuedfractions/*.py
unittests: clean
@echo "\n$(PACKAGE_NAME)[$(BRANCH)@$(HEAD)]: Running package unit tests + measuring coverage\n"
cd "$(PROJECT_ROOT)" && \
python3 -m pytest \
--cache-clear \
--capture=no \
--code-highlight=yes \
--color=yes \
--cov=src \
--cov-report=term-missing:skip-covered \
--dist worksteal \
--numprocesses=auto \
--tb=native \
--verbosity=3 \
tests/units