PYTHON ?= python3
COVERAGE ?= coverage

build:
	$(PYTHON) -m build

install: clean
	$(PYTHON) -m pip install --editable .

clean:
	$(PYTHON) setup.py clean
	rm -rf build
	rm -f smartcard/scard/_scard*.so

pypi: clean
	# files generated by swig
	rm -f smartcard/scard/scard.py
	rm -f smartcard/scard/scard_wrap.c
	# files generated by sphinx
	rm -rf smartcard/doc/_build
	# files generated by pydoctor
	rm -rf smartcard/doc/html
	rm -rf dist
	$(PYTHON) -m build
	python3 -m twine upload dist/*

test: install
	pytest

coverage:
	$(COVERAGE) erase
	$(COVERAGE) run -m unittest discover
	$(COVERAGE) report
	$(COVERAGE) html

ChangeLog.git:
	git log --stat --decorate=short > $@

.PHONY: clean build pypi test
