-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
57 lines (43 loc) · 1.17 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
# Copyright (c) 2020 Xvezda <[email protected]>
#
# Use of this source code is governed by an MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.
.PHONY: test build clean check publish
PY = python
PY2 = python2
PY3 = python3
TWINE = twine
TR = tr
RM = rm
CUT = cut
SED = sed
FIND = find
HEAD = head
GREP = grep
XARGS = xargs
PKG_NAME = $(shell $(FIND) . -maxdepth 2 -name '__init__.py' | $(CUT) -d'/' -f2 | $(HEAD) -n1)
METADATA_FILE = $(PKG_NAME)/__about__.py
PKG_VERSION = $(shell $(SED) -n -E "s/__version__ = [\"']([^\"']+)[\"']/\1/p" $(METADATA_FILE))
DIST_DIR = dist
DIST_FILES = $(wildcard $(DIST_DIR)/$(PKG_NAME)-$(PKG_VERSION)*)
TEST_DIR = tests
all: clean build
build: py2dist py3dist
py2dist:
$(PY2) setup.py sdist bdist_wheel
py3dist:
$(PY3) setup.py sdist bdist_wheel
check:
$(TWINE) check $(DIST_DIR)/$(PKG_NAME)-$(PKG_VERSION)*
publish: all check
$(TWINE) upload $(DIST_FILES)
pkg_version:
@echo $(PKG_VERSION)
clean:
$(GREP) '/$$' .gitignore \
| $(XARGS) -I{} echo "\\! -path '*/{}*'" \
| $(TR) $$'\n' ' ' | $(XARGS) $(FIND) . -name '*.pyc' \
| $(XARGS) -n1 $(RM)
$(PY) setup.py clean
$(RM) -rf build/