.PHONY: default wheel dev resize docs preview prepare release publish test

# shell option to use extended glob from from https://stackoverflow.com/a/6922447/1560241
SHELL:=/bin/bash -O extglob

# Single source of truth: pyproject.toml (kept in step with vuer_hub.__version__).
VERSION=$(shell grep -m1 '^version' pyproject.toml | cut -d'"' -f2)

author=$(Ge Yang)
author_email=$(ge.ike.yang@gmail.com)

# notes on python packaging: http://python-packaging.readthedocs.io/en/latest/minimal.html
default: publish release
wheel:
	rm -rf dist
	python -m build --wheel --sdist
dev:
	make wheel
	pip install --ignore-installed dist/vuer_hub-*.whl
resize: # from https://stackoverflow.com/a/28221795/1560241
	echo ./figures/!(*resized).jpg
	convert ./figures/!(*resized).jpg -resize 888x1000 -set filename:f '%t' ./figures/'%[filename:f]_resized.jpg'
preview:
	sphinx-autobuild --host 0.0.0.0 docs docs/_build/html
docs:
	rm -rf docs/_build
	cd docs && make html
	cd docs/_build/html && python -m http.server 8888
prepare:
	-git tag -d v$(VERSION)
	-git push origin --delete v$(VERSION)
	-git tag -d latest
	-git push origin --delete latest
release: prepare
	git push
	git tag v$(VERSION) -m '$(msg)'
	git tag latest
	git push origin --tags -f
publish:
	make wheel
	twine check dist/*
	twine upload dist/*
test:
	pwd && \
	python -m pytest tests --capture=no
