TARGET ?=
TARPAULIN_INSTALLED := $(shell command -v cargo-tarpaulin > /dev/null && echo 1 || echo 0)
.ONESHELL:
.PHONY: venv setup install install-release build-extension-debug build-extension-release watch-extension watch-extension-release pcc test test-rust test-python bench pybench doc dist clean check-clean-git check-tarpaulin test-rust-cov
.SILENT:
venv:
rm -rf .venv
python -m venv .venv
source .venv/bin/activate
pip install -U pip
setup:
pip install -e .[test]
pre-commit install
cargo install --force cargo-watch
cargo install --force cargo-run-script
install:
pip install -e .
install-release:
pip install .
build-extension-debug:
python setup.py build_rust --inplace --debug
build-extension-release:
python setup.py build_rust --inplace --release
watch-extension:
cargo watch -x 'run-script build-python-extension' -w src -w Cargo.toml
watch-extension-release:
cargo watch -x 'run-script build-python-extension-release' -w src -w Cargo.toml
pcc:
pre-commit run --all-files
test: test-python test-rust
test-rust:
cargo test "$(TARGET)"
test-python: build-extension-debug
pytest -svv tests -k "$(TARGET)" \
--cov=outlines_core \
--cov-report=term-missing:skip-covered
check-tarpaulin:
ifeq ($(TARPAULIN_INSTALLED), 0)
@echo "cargo-tarpaulin is not found, installing..."
cargo install cargo-tarpaulin
else
@echo "cargo-tarpaulin is already installed"
endif
test-rust-cov: check-tarpaulin
RUSTFLAGS="-C instrument-coverage" cargo tarpaulin \
--out=Lcov \
--output-dir=rust-coverage \
--engine=llvm \
--exclude-files=src/python_bindings/* \
--no-dead-code \
--workspace \
--verbose
bench:
ifeq ($(TARGET),)
cargo bench
else
cargo bench -- $(TARGET)
endif
pybench: check-clean-git
ifeq ($(TARGET),)
asv run --config benchmarks/asv.conf.json
else
asv run --config benchmarks/asv.conf.json -b "$(TARGET)"
endif
doc:
cargo doc --document-private-items --open
dist:
pip install build
python -m build
clean:
cargo clean
rm -rf dist
check-clean-git:
git diff-index --quiet HEAD \
|| (echo "Unable to perform the action due to uncommited local changes." && exit 1)