forked from SebKuzminsky/pycam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·140 lines (114 loc) · 4.6 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
# export SVN_REPO_BASE=. if you want to use the local version instead of trunk
# from the subversion repository.
PYTHON_EXE ?= python3
# use something like "VERSION=0.2 make" to override the VERSION on the command line
VERSION = $(shell $(PYTHON_EXE) -c 'import pycam; print(pycam.VERSION)')
VERSION_FILE = pycam/Version.py
REPO_TAGS ?= https://pycam.svn.sourceforge.net/svnroot/pycam/tags
DIST_DIR = dist
DIST_PREFIX = pycam-
DIST_TGZ = $(DIST_DIR)/$(DIST_PREFIX)$(VERSION).tar.gz
DIST_WIN32 = $(DIST_DIR)/$(DIST_PREFIX)$(VERSION).win32.exe
# check if the local version of python's distutils support "--plat-name"
# (introduced in python 2.6)
DISTUTILS_PLAT_NAME = $(shell $(PYTHON_EXE) setup.py --help build_ext \
| grep -q -- "--plat-name" && echo "--plat-name win32")
PYTHON_CHECK_STYLE_TARGETS = pycam pyinstaller/hooks/hook-pycam.py setup.py
# default location of mkdocs' build process
MKDOCS_SOURCE_DIR = docs
MKDOCS_EXPORT_DIR = site
MKDOCS_SOURCE_FILES = Makefile mkdocs.yml Changelog $(shell find "$(MKDOCS_SOURCE_DIR)" -type f)
MKDOCS_BUILD_STAMP = $(MKDOCS_EXPORT_DIR)/.build-stamp
# specify the remote user (e.g. for sourceforge: user,project) via ssh_config or directly on the
# commandline: "make upload-docs SF_USER=foobar"
ifdef SF_USER
WEBSITE_UPLOAD_PREFIX ?= $(SF_USER),pycam@
endif
WEBSITE_UPLOAD_LOCATION ?= web.sourceforge.net:/home/project-web/pycam/htdocs
RM = rm -f
.PHONY: build clean dist tgz win32 clean \
docs man upload-docs \
check-style pylint-relaxed pylint-strict test \
update-version update-deb-changelog
info:
@echo "Available targets:"
@echo " build"
@echo " clean"
@echo " dist"
@echo " docs"
@echo " man"
@echo " upload-docs"
@echo
@echo "Style checks:"
@echo " check-style"
@echo " pylint-relaxed"
@echo " pylint-strict"
build: man update-version
$(PYTHON_EXE) setup.py build
archive: tgz win32
@# we can/should remove the version file in order to avoid a stale local version
@$(RM) "$(VERSION_FILE)"
clean:
@$(RM) -r build
@$(RM) -r "$(MKDOCS_EXPORT_DIR)"
@$(RM) "$(VERSION_FILE)"
$(MAKE) -C man clean
man:
@$(MAKE) -C man man
$(DIST_DIR):
@mkdir -p "$@"
tgz: $(DIST_TGZ)
$(DIST_TGZ): $(DIST_DIR) build
$(PYTHON_EXE) setup.py sdist --format gztar --dist-dir "$(DIST_DIR)"
win32: $(DIST_WIN32)
$(DIST_WIN32): $(DIST_DIR) build
# this is a binary release
$(PYTHON_EXE) setup.py bdist_wininst --user-access-control force \
--dist-dir "$(DIST_DIR)" $(DISTUTILS_PLAT_NAME)
update-deb-changelog:
@# retrieve the log of all commits since the latest release and add it to the deb changelog
if ! grep -qFw "$(VERSION)" debian/changelog; then \
git log --pretty=format:%s v$(shell dpkg-parsechangelog | sed --quiet -re 's/Version: (.*)/\1/ p').. | \
DEBFULLNAME="PyCAM Builder" DEBEMAIL="[email protected]" \
xargs -r -d '\n' -n 1 -- debchange --newversion "$(subst -,.,$(VERSION))"; \
fi
update-version:
@echo 'VERSION = "$(VERSION)"' >| "$(VERSION_FILE)"
test: check-style pytest check-yaml-flow
# The "make pytest" target calls pytest via the obsolete `py.test` name,
# instead of the modern `pytest` name. This is in order to support
# older versions of pytest, specifically version 2.5 on Ubuntu Trusty.
# Once the oldest supported platform has pytest 3.0 or newer we can
# switch to the new `pytest` name.
pytest:
/usr/bin/py.test-3 -v .
check-style:
scripts/run_flake8 $(PYTHON_CHECK_STYLE_TARGETS)
check-yaml-flow:
$(RM) test.ngc
pycam/run_cli.py yaml_flow_working.yml
grep -q "Z" test.ngc
pylint-strict:
pylint $(PYTHON_CHECK_STYLE_TARGETS)
pylint-relaxed:
pylint -d missing-docstring,invalid-name,pointless-string-statement,fixme,no-self-use \
-d global-statement,unnecessary-pass,too-many-arguments,too-many-branches \
-d too-many-instance-attributes,too-many-return-statements \
-d too-few-public-methods,too-many-locals,using-constant-test \
-d attribute-defined-outside-init,superfluous-parens,too-many-nested-blocks \
-d too-many-statements,unused-argument,too-many-lines \
-d too-many-boolean-expressions,too-many-public-methods \
$(PYTHON_CHECK_STYLE_TARGETS)
## Building the documentation/website
docs: man $(MKDOCS_BUILD_STAMP)
@$(MAKE) -C man html
install -d "$(MKDOCS_EXPORT_DIR)/manpages/"
install --target-directory="$(MKDOCS_EXPORT_DIR)/manpages/" man/*.html
$(MKDOCS_BUILD_STAMP): $(MKDOCS_SOURCE_FILES)
sed 's/^Version/# Version/; s/^ \*/ */' Changelog \
>"$(MKDOCS_SOURCE_DIR)/release-notes.md"
mkdocs build
touch "$@"
upload-docs: docs
rsync -axz --delete --exclude=.DS_Store --exclude="$(notdir $(MKDOCS_BUILD_STAMP))" -e ssh \
"$(MKDOCS_EXPORT_DIR)/" "$(WEBSITE_UPLOAD_PREFIX)$(WEBSITE_UPLOAD_LOCATION)/"