-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
118 lines (87 loc) · 3.34 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
# Copyright (C) 2015 UCSC Computational Genomics Lab
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
define help
Supported targets: 'develop', 'sdist', 'clean', 'test', 'pypi', or 'pypi_stable'.
The 'develop' target creates an editable install (aka develop mode).
The 'sdist' target creates a source distribution of this project.
The 'clean' target undoes the effect of 'develop' and 'sdist'.
The 'test' target runs unit tests. Set the 'tests' variable to run a particular test.
The 'pypi' target publishes the current commit of Toil to PyPI after enforcing that the working
copy and the index are clean, and conditionally tagging it as an unstable .dev build if the
current project version is a pre-release, i.e. has an 'a123' or 'b123' suffix.
endef
export help
.PHONY: help
help:
@echo "$$help"
python=python2.7
tests=src
green=\033[0;32m
normal=\033[0m
red=\033[0;31m
.PHONY: develop
develop: _check_venv
$(python) setup.py egg_info develop
.PHONY: clean_develop
clean_develop: _check_venv
- $(python) setup.py develop -u
- rm -rf src/*.egg-info
.PHONY: sdist
sdist: _check_venv
$(python) setup.py sdist
.PHONY: clean_sdist
clean_sdist:
- rm -rf dist
.PHONY: test
test: _check_venv
$(python) setup.py test --pytest-args "-vv --assert=plain $(tests)"
.PHONY: pypi
pypi: _check_venv _check_clean_working_copy _check_running_on_jenkins
test "$$ghprbActualCommit" \
&& echo "We're building a PR, skipping PyPI." || ( \
set -x \
&& tag_build=`$(python) -c 'pass;\
from version import version as v;\
from pkg_resources import parse_version as pv;\
import os;\
print "--tag-build=.dev" + os.getenv("BUILD_NUMBER") if pv(v).is_prerelease else ""'` \
&& $(python) setup.py egg_info $$tag_build sdist bdist_egg upload )
.PHONY: clean_pypi
clean_pypi:
- rm -rf build/
.PHONY: clean
clean: clean_develop clean_sdist clean_pypi
-rm -rf __pychache__
-rm -rf .cache .eggs
find . -name '*.pyc' | xargs rm
.PHONY: _check_venv
_check_venv:
@$(python) -c 'import sys; sys.exit( int( not hasattr(sys, "real_prefix") ) )' \
|| ( echo "$(red)A virtualenv must be active.$(normal)" ; false )
.PHONY: _check_clean_working_copy
_check_clean_working_copy:
@echo "$(green)Checking if your working copy is clean ...$(normal)"
@git diff --exit-code > /dev/null \
|| ( echo "$(red)Your working copy looks dirty.$(normal)" ; false )
@git diff --cached --exit-code > /dev/null \
|| ( echo "$(red)Your index looks dirty.$(normal)" ; false )
@test -z "$$(git ls-files --other --exclude-standard --directory)" \
|| ( echo "$(red)You have are untracked files:$(normal)" \
; git ls-files --other --exclude-standard --directory \
; false )
.PHONY: _check_running_on_jenkins
_check_running_on_jenkins:
@echo "$(green)Checking if running on Jenkins ...$(normal)"
test -n "$$BUILD_NUMBER" \
|| ( echo "$(red)This target should only be invoked on Jenkins.$(normal)" ; false )