.DEFAULT_GOAL := all
sources = python/fastexcel python/tests
export CARGO_TERM_COLOR=$(shell (test -t 0 && echo "always") || echo "auto")
.PHONY: .uv
.uv:
@uv -V || echo 'Please install uv: https://docs.astral.sh/uv/getting-started/installation/'
.PHONY: install
install: .uv
uv sync --frozen --group all
uv run maturin develop --features __maturin --uv -E pandas,polars
.PHONY: install-prod
install-prod: .uv
uv sync --frozen --group all
uv run maturin develop --features __maturin --uv --release -E pandas,polars
.PHONY: setup-dev
setup-dev: install
uv run pre-commit install --install-hooks
.PHONY: rebuild-lockfiles
rebuild-lockfiles: .uv
uv lock --upgrade
cargo update
.PHONY: build-dev
build-dev:
uv run maturin build --features __maturin
.PHONY: build-wheel
build-wheel:
@rm -rf target/wheels/
uv run maturin build --release --features __maturin
@wheel=$$(ls target/wheels/*.whl); uv pip install --force-reinstall "$$wheel[pandas,polars]"
.PHONY: lint-python
lint-python:
uv run ruff check $(sources)
uv run ruff format --check $(sources)
uv run mypy $(sources)
.PHONY: lint-rust
lint-rust:
cargo fmt --all -- --check
cargo clippy --tests
cargo clippy --features __maturin --tests
cargo clippy --features polars --tests
.PHONY: lint
lint: lint-python lint-rust
.PHONY: format-python
format-python:
uv run ruff check --fix $(sources)
uv run ruff format $(sources)
.PHONY: format-rust
format-rust:
cargo fmt --all
cargo clippy --all-features --tests --fix --lib -p fastexcel --allow-dirty --allow-staged
.PHONY: format
format: format-rust format-python
.PHONY: test-python
test-python: install
uv run pytest
.PHONY: test-rust-pyo3
test-rust-pyo3:
cargo test --no-default-features --features __pyo3-tests --lib
.PHONY: test-rust-standalone
test-rust-standalone:
cargo test --no-default-features --features __rust-tests-standalone
.PHONY: test-rust-polars
test-rust-polars:
cargo test --no-default-features --features __rust-tests-polars
.PHONY: test-rust
test-rust: test-rust-pyo3 test-rust-standalone test-rust-polars
.PHONY: test
test: test-rust test-python
.PHONY: doc-serve
doc-serve: build-dev
uv run pdoc python/fastexcel
.PHONY: doc
doc: build-dev
uv run pdoc -o docs python/fastexcel
cargo doc --no-deps --lib -p fastexcel --features polars
.PHONY: all
all: format build-dev lint test
.PHONY: benchmarks
benchmarks: build-wheel
uv run pytest ./python/tests/benchmarks/speed.py
.PHONY: clean
clean:
rm -rf `find . -name __pycache__`
rm -f `find . -type f -name '*.py[co]' `
rm -f `find . -type f -name '*~' `
rm -f `find . -type f -name '.*~' `
rm -rf .cache
rm -rf htmlcov
rm -rf .pytest_cache
rm -rf *.egg-info
rm -f .coverage
rm -f .coverage.*
rm -rf build
rm -rf perf.data*
rm -rf python/fastexcel/*.so
.PHONY: help
help:
@grep -E \
'^.PHONY: .*?## .*$$' $(MAKEFILE_LIST) | \
sort | \
awk 'BEGIN {FS = ".PHONY: |## "}; {printf "\033[36m%-19s\033[0m %s\n", $$2, $$3}'