#
# Options
#

# Or you may want to select an explicit Python version, e.g. python3.9
PYTHON = python3

#
# Bit of an implementation detail: all scripts generated by buildout
#
scripts = bin/test bin/python bin/zodbbrowser

# my release rules
FILE_WITH_VERSION = src/zodbbrowser/__init__.py


#
# Interesting targets
#

.PHONY: all
all: $(scripts)                 ##: build a buildout

.PHONY: test
test:                           ##: run tests
	tox -p auto

# test with pager
.PHONY: testp
testp: bin/test                 ##: run tests in a pager
	bin/test -s zodbbrowser -vc 2>&1 |less -RFX

.PHONY: coverage
coverage:                       ##: measure test coverage
	tox -e coverage

.PHONY: checkzope2
checkzope2: dist python/bin/python  ##: (obsolete) run tests with zope2.cfg version pins
	version=`$(PYTHON) setup.py --version` && \
	rm -rf tmp && \
	mkdir tmp && \
	cd tmp && \
	tar xvzf ../dist/zodbbrowser-$$version.tar.gz && \
	cd zodbbrowser-$$version && \
	../../python/bin/python bootstrap.py && \
	bin/buildout -c zope2.cfg && \
	bin/test -s zodbbrowser


include release.mk


#
# Implementation
#

bin/buildout: python/bin/python bootstrap.py
	python/bin/pip install -U setuptools
	python/bin/python bootstrap.py

python/bin/python:
	virtualenv -p $(PYTHON) python

$(scripts): bin/buildout
	bin/buildout
	touch -c $(scripts)
