-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakefile
More file actions
117 lines (103 loc) · 4.62 KB
/
makefile
File metadata and controls
117 lines (103 loc) · 4.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
51
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
.SUFFIXES:
#command line flag, if nonemtpy disables timestamping in the version
RELEASE=
SRCFILES=$(shell git ls-files src/posets/*.py)
DATE:=$(if $(RELEASE),,$(shell date +".%y.%m.%d.%H.%M.%S" | sed -e 's/\.0/\./g'))
#Note, setting WHL on commandline doesn't have the expected effect
#because hatch makes the whl file name from the toml file
#use VERSION and DATE to override the whl name file if needed
WHL=dist/posets-$(VERSION)$(DATE)-py3-none-any.whl
PYDOX:=$(realpath $(shell which pydox))
VERSION:=$(shell grep -o 'version = "[^"]*' pyproject.toml | sed -e 's/version = "\([^"*]\)/\1/g')
TIMESTAMP:=$(shell date +"%y%m%d%H%M.%S")
#stem for publishing to test.pypi / pypi
TEST:=$(if $(RELEASE),,test.)
#command to use for installation
PIP:=python -m pip
#web browser for testing wasm
BROWSER=firefox
##########################################
#package recipes
##########################################
##############
#builds whl file for distribution using version from pyproject.toml or commandline if set and appending the current date
#set DATE= on commandline to build without the date in the version
##############
$(WHL) : pyproject.toml $(SRCFILES)
#set version
sed -e 's/version = "\([^"]*\)"/version = "\1$(DATE)"/g' $< > $<. && mv $<. $<
#build
hatch build
#unset version
sed -e 's/version = "[^"]*"/version = "$(VERSION)"/g' $< > $<. && mv $<. $<
#fix timestamp for future make calls
touch -t $(TIMESTAMP) $<
##############
#publish to pypi
##############
.PHONY : publish
publish : $(TEST)pypi.token.gpg $(WHL) README.md
python -m twine upload --verbose --repository-url "https://$(if $(TEST),test,upload).pypi.org/legacy/" -u __token__ -p "$$(gpg --pinentry-mode loopback -q --decrypt $<)" dist/posets-$(VERSION)$(DATE).tar.gz $(WHL)
.PHONY : release
release : publish
git tag v$(VERSION)$(DATE)
git push origin tag v$(VERSION)$(DATE)
gh release create $(if $(RELEASE),,-d) --notes-from-tag v$(VERSION)$(DATE) $(WHL) $(patsubst %-py3-none-any.whl,%.tar.gz,$(WHL)) docs/posets.pdf
##############
#install package
##############
.PHONY : install
install : $(WHL)
$(PIP) install $(PIP_FLAGS) $(WHL)
##########################################
#documention recipes
##########################################
##############
#main pdf documentation
##############
docs : docs/posets.pdf
@:
docs/bib.tex :
printf '\\bibliography{bib}{}\n\\bibliographystyle{plain}' > $@
docs/posets.pdf : $(SRCFILES) docs/posets.sty docs/doc_funcs.py docs/bib.tex $(PYDOX) install
cd docs; $(PYDOX) --module ../src/posets --compile bibtex --impall doc_funcs --date today --author William\ Gustafson --title Posets --post bib.tex --subtitle v$(VERSION)$(DATE)
##############
#README is autogenerated from the module doc string
#via pandoc plus some tricks to get the references well formed
##############
README.md : src/posets/__init__.py docs/csl.csl
cd docs;python -c 'import sys;sys.path.append("../src");import posets;print(posets.__doc__,end="")' | head -n -1 | tail -n +3 | sed -e 's/\\\([abcd]\)v/\\textbf{\1}/g' | cat posets.sty - bib.tex | pandoc --csl csl.csl --bibliography bib.bib -C -f latex -t gfm | tail -n +2 | sed -e 's/\(<div id="refs"\)/# References\n\1/' | sed -e 's/\\\[\([0-9]\)\\\]/[\\[\1\\]](#references)/g' | sed -e 's/\\\([{}]\)/\\\\\1/g' | sed -e 's/\\@/@/g' > ../$@
#file specifying references format
docs/csl.csl :
wget -O $@ https://www.zotero.org/styles/acm-sigchi-proceedings
##########################################
#test recipes
##########################################
.PHONY : test wasmtest
#run pytest
test :
cd tests && pytest posets_test.py -vvv
#make html file to test compatibility under pyodide
.PHONY : wasm.test.html
wasm.test.html : tests/wasm.test tests/posets_test.py
lineno=$$(grep -n '^#Test pythonPosetToMac' $(lastword $^) | sed -e 's/\(.*\):.*/\1/g') && cat $< | sed -e 's/{WHL}/$(subst /,\/,$(WHL))/g' > $@.tmp && head -n $$lineno $(lastword $^) | cat $@.tmp - tests/bootleg.pytest.py > $@
printf "\n</p></body></html>" >> $@
rm $@.tmp
#run tests under pyodide (through the browser)
wasmtest : wasm.test.html $(WHL)
$(info Starting a local web server. Navigate to the url below in your favorite web browser.)
$(info localhost:8000/$<)
python -m http.server
coverage : tests/htmlcov/index.html
tests/htmlcov/index.html : $(SRCFILES) tests/posets_test.py
cd tests; coverage run --source ../src/posets -m pytest posets_test.py; coverage html
##############
#removes latex intermediary files and hatch build outputs
#this includes figure pdfs
##############
.PHONY : clean
clean :
rm -rf docs/figures/*
rm -rf docs/*.aux docs/*.blg docs/*.log docs/*.toc docs/*.bbl docs/*.out docs/*.toc docs/*.tex
rm -rf dist/*
rm -rf wasm.test.html