Makefile 2.75 KB
Newer Older
dboe's avatar
dboe committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
SHELL := /bin/bash # Use bash syntax
CURRENT_PATH := $(shell pwd)
MODULE := $(shell basename "$(CURRENT_PATH)")
VERSION := $(shell python -c "import sys; import $(MODULE); sys.stdout.write($(MODULE).__version__)")
SOURCES := $(shell find $(MODULE) -name '*.py')
DOCUMENTATION := $(shell find . -name '*.rst')
SPHINXOPTS    ?=
SPHINXBUILD   ?= sphinx-build
SPHINXSOURCEDIR = ./docs
SPHINXBUILDDIR  = docs/_build
GITSTATUS = $(shell git status --porcelain)
part ?= patch

test: FORCE
	flake8 rna tests
dboe's avatar
dboe committed
16
	pylint rna tests
dboe's avatar
dboe committed
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
	py.test

coverage:
	# coverage run $(MODULE) test
	py.test --cov=$(MODULE) || true
	# coverage report
	coverage html
	python -m webbrowser htmlcov/index.html

clean:
	coverage erase
	rm -rf htmlcov
	rm -rf docs/_build
	rm -rf docs/source
	rm -rf dist
	rm -rf report
	rm -rf .tox
	rm -rf .pytest_cache
	rm -rf *.egg-info
	pre-commit clean

publish:
	# call optional with argument: make part=minor publish
	bump2version $(part)  # possible: major / minor / patch
	git push
	git push --tags

untag:
	# remove last tag. mostly, because publishing failed
	git tag -d v$(VERSION)
	git push origin :refs/tags/v$(VERSION)

requirements: setup.cfg
	# We have all the information in the setup.cfg file. For some reasons (e.g. bug in setuptools or limitations to use setup.cfg in readthedocs) we still need a requirements file
dboe's avatar
dboe committed
51
	python -c "import configparser; import os; config = configparser.ConfigParser(); config.read('setup.cfg'); deps = config['options']['install_requires'].split('\n'); deps = [x for x in deps if x]; head = '# Autogenerated by Makefile from setup.cfg install_requies section. Remove this line if you want to fix this file.'; path = 'requirements.txt'; f = open(path, 'r') if os.path.exists(path) else None; line = f.readline() if f else ''; quit('User defined requirements already existing.') if f and not line.startswith(head[:20]) else None; f = open('requirements.txt', 'w'); f.write('\n'.join([head] + deps))"
dboe's avatar
dboe committed
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

doc: Makefile $(SOURCES) $(DOCUMENTATION) docs/conf.py docs/apidoc-template/*
	# link apidoc to source and build html documentation with sphinx
	python setup.py build_sphinx
	# manual version would be
	# # link apidoc to source
	# sphinx-apidoc -o docs/source/ $(MODULE)
	# # build html documentation with sphinx
	# # @$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(0)
	# sphinx-build -M html docs docs/_build
	#
	# open the html slides
	python -m webbrowser docs/_build/html/index.html

update:
	# get up to date with the cookiecutter template 'dough'
	# first check that no changes are existing
	@echo $(GITSTATUS)
	@if [ -z $(GITSTATUS) ]; then \
	  	echo "Working directory clean."; \
	else \
		git status; \
	  	echo "Your status is not clean! I can not update!"; \
	    exit 1; \
	fi
	# Starting upgrade
	cookiecutter_project_upgrader

FORCE: ;