coren 0.1.5

Machine capability detection and compute normalization
Documentation
.PHONY: dev test pub clean

BUMP ?= patch
PYVER := $(shell uv run python -c "import sys; print(f'python3.{sys.version_info.minor}')")
CUR := $(shell sed -n 's/^version = "\(.*\)"/\1/p' pyproject.toml | head -1)
NEW  = $(if $(V),$(V),$(shell echo $(CUR) | awk -F. '{ \
	if ("$(BUMP)"=="major") printf "%s.0.0",$$1+1; \
	else if ("$(BUMP)"=="minor") printf "%s.%s.0",$$1,$$2+1; \
	else printf "%s.%s.%s",$$1,$$2,$$3+1 }'))

dev:
	uv run maturin develop --release

test:
	cargo test
	uv run pytest

# Publish:  make pub  |  make pub BUMP=minor  |  make pub V=0.2.0
pub:
	@test -f .pypirc || (echo "Missing .pypirc" && exit 1)
	@test -f .cargo-credentials || (echo "Missing .cargo-credentials" && exit 1)
	@echo "$(CUR) -> $(NEW)"
	sed -i 's/^version = "$(CUR)"/version = "$(NEW)"/' pyproject.toml Cargo.toml
	rm -rf dist/
	uv run maturin build --release --zig --target x86_64-unknown-linux-gnu  --manylinux 2_17 --out dist/
	uv run maturin build --release --zig --target aarch64-unknown-linux-gnu --manylinux 2_17 --out dist/ -i $(PYVER)
	uv run maturin sdist --out dist/
	uv run twine upload -r coren --config .pypirc dist/*
	cargo publish --allow-dirty --token "$$(grep '^token' .cargo-credentials | sed 's/.*= *"\(.*\)"/\1/')"
	git add -A && git commit -m "v$(NEW)" && git tag "v$(NEW)" && git push origin main --tags

clean:
	cargo clean
	rm -rf dist/ .venv/ *.egg-info/