Skip to content

Commit 8d464a5

Browse files
authored
The fifth revision (#10)
1 parent f5f2557 commit 8d464a5

46 files changed

Lines changed: 2583 additions & 1582 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# EditorConfig is awesome: https://EditorConfig.org
2-
31
# Top-most EditorConfig file
42
root = true
53

@@ -19,7 +17,7 @@ max_line_length = 100
1917
# Markdown files
2018
[*.md]
2119
max_line_length = 120
22-
trim_trailing_whitespace = false # Don't remove trailing whitespace in Markdown files
20+
trim_trailing_whitespace = false
2321

2422
# Bash scripts
2523
[*.sh]
@@ -29,3 +27,6 @@ indent_size = 2
2927
[*.{yaml,yml}]
3028
indent_size = 2
3129

30+
# Python files
31+
[*.py]
32+
max_line_length = 100
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
name: Run Benchmarks
22

33
on:
4-
workflow_dispatch: { } # Allow manual execution
4+
workflow_dispatch:
55

66
jobs:
7-
build:
7+
benchmarks:
88
runs-on: ubuntu-latest
99

1010
strategy:
1111
matrix:
1212
# Define the Rust versions to test against
13-
rust-version: [ "stable", "beta" ]
13+
rust-version: [ "1.83.0", "stable", "beta" ]
1414

1515
steps:
1616
- name: Checkout Repository
@@ -24,7 +24,7 @@ jobs:
2424
- name: Install Dependencies
2525
run: |
2626
sudo apt-get update
27-
sudo apt-get install -y make
27+
sudo apt-get install -y clang curl pkg-config libssl-dev make
2828
make install-deps
2929
3030
- name: Run Benchmarks

.github/workflows/lints.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
name: Run Linters
1+
name: Run Linter Checks
22

33
on:
4-
workflow_dispatch: { } # Allow manual execution
5-
push:
6-
tags:
7-
- 'v*' # Trigger on version tags
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: read
811

912
jobs:
1013
lint:

.github/workflows/publish.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
name: Publish to Crates.io
22

33
on:
4-
workflow_dispatch: { } # Allow manual execution
4+
workflow_dispatch:
55
push:
66
tags:
7-
- 'v*' # Trigger on version tags
7+
- 'v*'
8+
9+
permissions:
10+
contents: read
811

912
jobs:
1013

@@ -33,6 +36,7 @@ jobs:
3336
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
3437
run: |
3538
sudo apt-get update
36-
sudo apt-get install -y make
39+
sudo apt-get install -y clang curl pkg-config libssl-dev make
40+
make install-deps
3741
cargo publish --token $CARGO_REGISTRY_TOKEN
38-
continue-on-error: false
42+
continue-on-error: false

.github/workflows/publish_py.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish PySpart to PyPI
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- 'v*'
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
publish_to_pypi:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout Repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set Up Python
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: "3.10"
24+
25+
- name: Install Dependencies
26+
run: |
27+
pip install -U pip
28+
pip install uv
29+
uv sync --all-extras
30+
31+
- name: Build and Publish Package
32+
run: |
33+
make wheel-manylinux
34+
env PYPI_TOKEN=${{ secrets.PYPI_API_TOKEN }} make publish-py

.github/workflows/tests.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
name: Run Tests
22

33
on:
4-
workflow_dispatch: { } # Allow manual execution
5-
workflow_call: # Make this workflow callable from other workflows
4+
workflow_dispatch:
5+
workflow_call:
6+
pull_request:
7+
branches:
8+
- main
9+
10+
permissions:
11+
contents: read
612

713
jobs:
8-
build:
14+
tests:
915
runs-on: ubuntu-latest
1016

1117
strategy:
1218
matrix:
1319
# Define the Rust versions to test against
14-
rust-version: [ "1.83.0", "1.84.0", "beta", "stable" ]
20+
rust-version: [ "1.83.0", "stable", "beta" ]
1521

1622
steps:
1723
- name: Checkout Repository
@@ -25,7 +31,7 @@ jobs:
2531
- name: Install Dependencies
2632
run: |
2733
sudo apt-get update
28-
sudo apt-get install -y make
34+
sudo apt-get install -y clang curl pkg-config libssl-dev make
2935
make install-deps
3036
3137
- name: Run Tests and Generate Coverage Report

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,6 @@ rtree_2d.dot
8989
rtree_3d.dot
9090
src/main.rs
9191
.benchmarks
92+
*.log
93+
*_output.txt
94+
pyspart/target/

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ would like to work on or if it has already been resolved.
1111
### Reporting Bugs
1212

1313
1. Open an issue on the [issue tracker](https://github.com/habedi/spart/issues).
14-
2. Include information such as steps to reproduce, expected/actual behavior, and relevant logs or screenshots.
14+
2. Include information such as steps to reproduce the bug, expected behavior, and actual behavior.
1515

1616
### Suggesting Features
1717

Cargo.toml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "spart"
3-
version = "0.1.4"
3+
version = "0.2.0"
44
description = "A collection of space partitioning tree data structures for Rust"
55
repository = "https://github.com/habedi/spart"
66
license = "MIT OR Apache-2.0"
@@ -11,6 +11,9 @@ homepage = "https://github.com/habedi/spart"
1111
documentation = "https://docs.rs/spart"
1212
categories = ["data-structures", "algorithms"]
1313
edition = "2021"
14+
rust-version = "1.83.0"
15+
16+
resolver = "2"
1417

1518
[lib]
1619
name = "spart"
@@ -20,10 +23,10 @@ path = "src/lib.rs"
2023
tracing = "0.1.41"
2124
tracing-subscriber = "0.3.19"
2225
ordered-float = "5.0.0"
23-
ctor = "0.4.1"
26+
ctor = "0.5.0"
2427

2528
[dev-dependencies]
26-
criterion = { version = "0.5", features = ["html_reports"] }
29+
criterion = { version = "0.7.0", features = ["html_reports"] }
2730

2831
[[bench]]
2932
name = "main"
@@ -40,6 +43,22 @@ debug = true
4043
[profile.test]
4144
debug = true
4245

46+
[[example]]
47+
name = "quadtree"
48+
path = "examples/quadtree.rs"
49+
50+
[[example]]
51+
name = "octree"
52+
path = "examples/octree.rs"
53+
54+
[[example]]
55+
name = "kdtree"
56+
path = "examples/kdtree.rs"
57+
58+
[[example]]
59+
name = "rtree"
60+
path = "examples/rtree.rs"
61+
4362
[package.metadata.rustfmt]
4463
max_width = 100
4564
hard_tabs = false

Makefile

Lines changed: 90 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,22 @@ BINARY = :target/release/$(BINARY_NAME)
55
PATH := /snap/bin:$(PATH)
66
RUST_BACKTRACE := 0
77
DEBUG_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
1826
format: ## 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
4367
clean: ## 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
4874
install-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
6491
lint: 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
94121
fix-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

Comments
 (0)