@@ -5,14 +5,22 @@ BINARY = :target/release/$(BINARY_NAME)
55PATH := /snap/bin:$(PATH )
66RUST_BACKTRACE := 0
77DEBUG_SPART := 0
8+ RUST_LOG := info
9+ WHEEL_DIR := dist
10+ PYSPART_DIR := pyspart
11+ PY_DEP_MNGR := uv
12+ WHEEL_FILE := $(shell ls $(PYSPART_DIR ) /$(WHEEL_DIR ) /pyspart-* .whl 2>/dev/null | head -n 1)
813
914# Default target
1015.DEFAULT_GOAL := help
1116
1217.PHONY : help
13- help : # # Show the help message for each target
14- @grep -E ' ^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | awk ' BEGIN {FS = ":.*?## "}; \
15- {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
18+ help : # # Show the help messages for all targets
19+ @echo " Usage: make <target>"
20+ @echo " "
21+ @echo " Targets:"
22+ @grep -E ' ^[a-zA-Z_-]+:.*## .*$$' Makefile | \
23+ awk ' BEGIN {FS = ":.*## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
1624
1725.PHONY : format
1826format : # # Format Rust files
@@ -39,10 +47,28 @@ run: build ## Build and run the binary
3947 @echo " Running the $( BINARY) binary..."
4048 @DEBUG_SPART=$(DEBUG_SPART ) ./$(BINARY )
4149
50+ .PHONY : run-examples
51+ run-examples : build # # Run the Rust examples
52+ @echo " Running Rust examples..."
53+ @cargo run --example quadtree
54+ @cargo run --example octree
55+ @cargo run --example kdtree
56+ @cargo run --example rtree
57+
58+ .PHONY : run-py-examples
59+ run-py-examples : develop-py # # Run the Python examples
60+ @echo " Running Python examples..."
61+ @$(PY_DEP_MNGR ) run python pyspart/examples/quadtree.py
62+ @$(PY_DEP_MNGR ) run python pyspart/examples/octree.py
63+ @$(PY_DEP_MNGR ) run python pyspart/examples/kdtree.py
64+ @$(PY_DEP_MNGR ) run python pyspart/examples/rtree.py
65+
4266.PHONY : clean
4367clean : # # Remove generated and temporary files
4468 @echo " Cleaning up..."
4569 @cargo clean
70+ @rm -rf $(WHEEL_DIR ) dist/ $(PYSPART_DIR ) /$(WHEEL_DIR )
71+ @rm -f $(PYSPART_DIR ) /* .so
4672
4773.PHONY : install-snap
4874install-snap : # # Install a few dependencies using Snapcraft
@@ -57,8 +83,9 @@ install-deps: install-snap ## Install development dependencies
5783 @echo " Installing dependencies..."
5884 @rustup component add rustfmt clippy
5985 @cargo install cargo-tarpaulin
60- @cargo install cargo-audit
61- @cargo install nextest
86+ @cargo install --locked cargo-nextest --version 0.9.97-b.2
87+ @sudo apt-get install -y python3-pip
88+ @pip install $(PY_DEP_MNGR )
6289
6390.PHONY : lint
6491lint : format # # Run linters on Rust files
@@ -85,12 +112,68 @@ nextest: ## Run tests using nextest
85112 @echo " Running tests using nextest..."
86113 @DEBUG_SPART=$(DEBUG_SPART ) RUST_BACKTRACE=$(RUST_BACKTRACE ) cargo nextest run
87114
88- .PHONY : doc
89- doc : format # # Generate the documentation
115+ .PHONY : docs
116+ docs : format # # Generate the documentation
90117 @echo " Generating documentation..."
91118 @cargo doc --no-deps --document-private-items
92119
93120.PHONY : fix-lint
94121fix-lint : # # Fix the linter warnings
95122 @echo " Fixing linter warnings..."
96123 @cargo clippy --fix --allow-dirty --allow-staged --all-targets --workspace --all-features -- -D warnings
124+
125+ # #######################################################################################
126+ # # Python targets
127+ # #######################################################################################
128+
129+ .PHONY : develop-py
130+ develop-py : # # Build and install PySpart in the current Python environment
131+ @echo " Building and installing PySpart..."
132+ # Note: Maturin does not work when CONDA_PREFIX and VIRTUAL_ENV are both set
133+ @ (cd $( PYSPART_DIR) && unset CONDA_PREFIX && maturin develop)
134+
135+ .PHONY : wheel
136+ wheel : # # Build the wheel file for PySpart
137+ @echo " Building the PySpart wheel..."
138+ @ (cd $( PYSPART_DIR) && maturin build --release --out $( WHEEL_DIR) --auditwheel check)
139+
140+ .PHONY : wheel-manylinux
141+ wheel-manylinux : # # Build the manylinux wheel file for PySpart (using Zig)
142+ @echo " Building the manylinux PySpart wheel..."
143+ @ (cd $( PYSPART_DIR) && maturin build --release --out $( WHEEL_DIR) --auditwheel check --zig)
144+
145+ .PHONY : test-py
146+ test-py : develop-py # # Run Python tests
147+ @echo " Running Python tests..."
148+ @$(PY_DEP_MNGR ) run pytest
149+
150+ .PHONY : publish-py
151+ publish-py : wheel-manylinux # # Publish the PySpart wheel to PyPI (requires PYPI_TOKEN to be set)
152+ @echo " Publishing PySpart to PyPI..."
153+ @if [ -z " $( WHEEL_FILE) " ]; then \
154+ echo " Error: No wheel file found. Please run 'make wheel' first." ; \
155+ exit 1; \
156+ fi
157+ @echo " Found wheel file: $( WHEEL_FILE) "
158+ @twine upload -u __token__ -p $(PYPI_TOKEN ) $(WHEEL_FILE )
159+
160+ .PHONY : generate-ci
161+ generate-ci : # # Generate CI configuration files (GitHub Actions workflow)
162+ @echo " Generating CI configuration files..."
163+ @ (cd $( PYSPART_DIR) && maturin generate-ci --zig --pytest --platform all -o ../.github/workflows/ci.yml github)
164+
165+ # #######################################################################################
166+ # # Additional targets
167+ # #######################################################################################
168+
169+ .PHONY : setup-hooks
170+ setup-hooks : # # Install Git hooks (pre-commit and pre-push)
171+ @echo " Installing Git hooks..."
172+ @pre-commit install --hook-type pre-commit
173+ @pre-commit install --hook-type pre-push
174+ @pre-commit install-hooks
175+
176+ .PHONY : test-hooks
177+ test-hooks : # # Test Git hooks on all files
178+ @echo " Testing Git hooks..."
179+ @pre-commit run --all-files
0 commit comments