# make dist -- builds grobx-sage's sdist and wheel into dist/.
# make test -- installs that wheel under Sage in the image SAGE_IMAGE, with the newest grobx on PyPI,
# and runs test_grobx_sage.py against it.

SAGE_IMAGE ?= sagemath/sagemath:10.10

.PHONY: dist test

dist:
	rm -rf dist
	uv build --out-dir dist

# The files reach the container as a tar on stdin: its user sage cannot read a bind mount of a home
# directory that is closed to others. The test runs where no grobx_sage.py lies, so it imports the
# wheel's.
test: dist
	tar -c dist/*.whl test_grobx_sage.py | docker run --rm -i --entrypoint bash $(SAGE_IMAGE) -c \
	  'set -e; cd "$$(mktemp -d)"; tar -x; sage -pip install -q --upgrade dist/*.whl; \
	   sage -python -m pytest -q -p no:cacheprovider test_grobx_sage.py'
