66# https://github.com/btschwertfeger
77#
88
9- VENV := venv
9+ UV := uv
1010PYTHON := python
11+ PYTEST := $(UV ) run pytest
1112TESTS := tests
12- PYTEST_OPTS := -vv
13- ROOT_DIR: = $( shell dirname $( realpath $( firstword $( MAKEFILE_LIST ) ) ) )
13+ PYTEST_OPTS := -vv --junit-xml=pytest.xml
14+ PYTEST_COV_OPTS := $( PYTEST_OPTS ) --cov=cmethods --cov-report=xml:coverage.xml --cov-report=term
1415
16+ # # ======= M A K E F I L E - T A R G E T S =====================================
17+ # # help Show this help message
18+ # #
1519.PHONY : help
1620help :
1721 @grep " ^##" Makefile | sed -e " s/##//"
1822
19- # # build Builds python-cmethods
23+ # # ======= B U I L D I N G =====================================================
24+ # # build Builds the package
2025# #
2126.PHONY : build
2227build :
2328 $(PYTHON ) -m build .
2429
30+ # # rebuild Rebuild the package
31+ # #
32+ .PHONY : rebuild
33+ rebuild : clean build
34+
35+ # # ======= I N S T A L L A T I O N =============================================
36+ # # install Install the package
37+ # #
38+ .PHONY : install
39+ install : check-uv
40+ $(UV ) pip install .
41+
2542# # dev Installs the package in edit mode
2643# #
2744.PHONY : dev
2845dev :
2946 @git lfs install
30- $(PYTHON ) -m pip install -e " .[dev,test,jupyter,examples]" -r doc/requirements.txt
31-
32- # # install Install the package
33- # #
34- .PHONY : install
35- install :
36- $(PYTHON ) -m pip install .
47+ $(UV ) pip install -e " .[dev,test,jupyter,examples]" -r doc/requirements.txt
3748
49+ # # ======= T E S T I N G =======================================================
3850# # test Run the unit tests
3951# #
4052.PHONY : test
@@ -50,13 +62,19 @@ tests: test
5062retest :
5163 $(PYTHON ) -m pytest $(PYTEST_OPTS ) --lf $(TESTS )
5264
53-
5465# # wip Run tests marked as wip
5566# #
5667.PHONY : wip
5768wip :
5869 $(PYTHON ) -m pytest $(PYTEST_OPTS ) -m " wip" $(TESTS )
5970
71+ # # coverage Run all tests and generate the coverage report
72+ # #
73+ .PHONY : coverage
74+ coverage :
75+ @rm .cache/tests/* .log || true
76+ $(PYTEST ) $(PYTEST_COV_OPTS ) $(TEST_DIR )
77+
6078# # doc Build the documentation
6179# #
6280.PHONY : doc
6987doctest :
7088 cd doc && make doctest
7189
72- # # pre-commit Pre-Commit
90+ # # ======= M I S C E L A N I O U S =============================================
91+ # # pre-commit Run the pre-commit targets
7392# #
7493.PHONY : pre-commit
7594pre-commit :
@@ -92,7 +111,7 @@ ruff-fix:
92111.PHONY : changelog
93112changelog :
94113 docker run -it --rm \
95- -v $(ROOT_DIR ) :/usr/local/src/your-app/ \
114+ -v $(PWD ) :/usr/local/src/your-app/ \
96115 githubchangeloggenerator/github-changelog-generator \
97116 -u btschwertfeger \
98117 -p python-cmethods \
@@ -115,3 +134,12 @@ clean:
115134 find tests -name "__pycache__" | xargs rm -rf
116135 find cmethods -name "__pycache__" | xargs rm -rf
117136 find examples -name "__pycache__" | xargs rm -rf
137+
138+ # # check-uv Check if uv is installed
139+ # #
140+ .PHONY : check-uv
141+ check-uv :
142+ @if ! command -v $(UV ) > /dev/null; then \
143+ echo " Error: uv is not installed. Please visit https://github.com/astral-sh/uv for installation instructions." ; \
144+ exit 1; \
145+ fi
0 commit comments