forked from LRGASP/lrgasp-submissions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
155 lines (121 loc) · 4.74 KB
/
Makefile
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
PYTHON = python3
FLAKE8 = python3 -m flake8
export PYTHONPATH = lib
TWINE = ${PYTHON} -m twine
VULTURE = vulture
pyprogs = $(shell file -F $$'\t' bin/* | awk '/Python script/{print $$1}')
pyotherprogs = $(shell file -F $$'\t' devs/bin/* tests/*/bin/* | awk '/Python script/{print $$1}')
pypi_url = https://upload.pypi.org/simple/
testpypi_url = https://test.pypi.org/simple/
testenv = testenv
version = $(shell PYTHONPATH=lib ${PYTHON} -c "import lrgasp; print(lrgasp.__version__)")
# mdl is an uncommon program to verify markdown
have_mdl = $(shell which mdl >&/dev/null && echo yes || echo no)
have_mdlinkcheck = $(shell which markdown-link-check >&/dev/null && echo yes || echo no)
github_pages_url = https://lrgasp.github.io/lrgasp-submissions/docs/
help:
@echo "clean - remove all build, test, coverage and Python artifacts"
@echo "doc - build various pieces of the doc"
@echo "lint - check style with flake8"
@echo "lint-doc - check documentation"
@echo "lint-all - lint plus lint-doc"
@echo "lint-pages - lint github pages, must have been pushed first"
@echo "vulture - find unused code"
@echo "test - run tests quickly with the default Python"
@echo "install - install the package to the active Python's site-packages"
@echo "dist - package"
@echo "test-pip - test install the package using pip"
@echo "release-testpypi - test upload to testpypi"
@echo "test-release-testpypi - install from testpypi"
@echo "release - package and upload a release"
@echo "test-release - test final release"
data_matrix_tsv = docs/rnaseq-data-matrix.tsv
submit_tree_png = docs/submit_tree.png
# data matrix HTML is only built on hgwdev or if htmldir is set on the commandline
ifeq ($(shell hostname),hgwdev)
htmldir = ${HOME}/public_html/lrgasp
endif
ifneq (${htmldir},)
data_matrix_html = ${htmldir}/rnaseq-data-matrix.html
endif
doc: ${data_matrix_tsv} ${data_matrix_html} ${submit_tree_png}
${data_matrix_tsv}: $(wildcard lib/lrgasp/data/*.json) \
lib/lrgasp/data_sets.py devs/bin/generateRnaSeqDataMatrix
./devs/bin/generateRnaSeqDataMatrix
${data_matrix_html}: ${data_matrix_tsv} devs/bin/make_html_table.R
Rscript devs/bin/make_html_table.R ${data_matrix_html}
${submit_tree_png}: devs/bin/genSubmitTree
devs/bin/genSubmitTree $@
# edit function also validates format and field names
lint:
${FLAKE8} ${pyprogs} ${pyotherprogs} lib
devs/bin/editExampleJson --clean entry templates/entry.json
devs/bin/editExampleJson --clean experiment templates/experiment.json
# requires the NPM packages:
# remark-cli remark-lint remark-preset-lint-recommended markdown-link-check
lint-doc: check-doc-format check-doc-links
lint-all: lint lint-doc
ifeq (${have_mdl},yes)
check-doc-format:
mdl --style=mdl-style.rb README.md docs
else
check-doc-format:
@echo "Note: mdl not installed, not linting markdown" >&2
endif
ifeq (${have_mdlinkcheck},yes)
mdfiles = $(wildcard README.md docs/*.md)
check-doc-links: ${mdfiles:%=check-doc-links_%}
check-doc-links_%:
markdown-link-check --config=markdown-link-check.json $*
check-doc-links_docs/%:
markdown-link-check --config=markdown-link-check.json docs/$*
else
check-doc-links:
@echo "Note: markdown-link-check not installed, not checking markdown links" >&2
endif
lint-pages:
linkchecker ${github_pages_url}
# this gets a lot of false-positive, just use for code cleanup rather than making it
# standard
vulture:
${VULTURE} ${pyprogs} lib
test:
cd tests && ${MAKE} test
clean: test_clean
rm -rf build/ dist/ ${testenv}/ lib/lrgasp_tools.egg-info/ lib/lrgasp/__pycache__/
test_clean:
cd tests && ${MAKE} clean
define envsetup
@rm -rf ${testenv}/
mkdir -p ${testenv}
${PYTHON} -m virtualenv ${testenv}
endef
envact = source ${testenv}/bin/activate
dist_tar = dist/lrgasp-tools-${version}.tar.gz
dist_whl = dist/lrgasp_tools-${version}-py3-none-any.whl
pkgver_spec = lrgasp-tools==${version}
dist: clean
${PYTHON} setup.py sdist
${PYTHON} setup.py bdist_wheel
@ls -l ${dist_tar}
@ls -l ${dist_whl}
# test install locally
test-pip: dist
${envsetup}
${envact} && cd ${testenv} && pip install --no-cache-dir $(realpath ${dist_tar})
${envact} && cd tests ${MAKE} test
# test release to testpypi
release-testpypi: dist
${TWINE} upload --repository=testpypi ${dist_whl} ${dist_tar}
# test release install from testpypi
# for some reason, pip sees lrgasp in lib directory and doesn't install it, so cd to virtualenv
test-release-testpypi:
${envsetup}
${envact} && cd ${testenv} && pip install --no-cache-dir --index-url=${testpypi_url} --extra-index-url=https://pypi.org/simple ${pkgver_spec}
${envact} && cd tests && ${MAKE} test
release: dist
${TWINE} upload --repository=pypi ${dist_whl} ${dist_tar}
test-release:
${envsetup}
${envact} && cd ${testenv} && pip install --no-cache-dir ${pkgver_spec}
${envact} && cd tests && ${MAKE} test