forked from NervanaSystems/ngraph-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
122 lines (102 loc) · 3.55 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
# ----------------------------------------------------------------------------
# Copyright 2016 Nervana Systems Inc.
# 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.
# ----------------------------------------------------------------------------
# set empty to prevent any implicit rules from firing.
.SUFFIXES:
# Extract virtualenv Python version
PY := $(shell python --version 2>&1 | cut -c8)
ifeq ($(PY), 2)
PYLINT3K_ARGS := --disable=no-absolute-import,setslice-method,getslice-method,nonzero-method
else
PYLINT3K_ARGS :=
endif
# style checking related
STYLE_CHECK_OPTS :=
STYLE_CHECK_DIRS := ngraph tests examples
# pytest options
TEST_OPTS :=
TEST_DIRS := tests/ ngraph/frontends/tensorflow/tests/ ngraph/frontends/neon/tests
# this variable controls where we publish Sphinx docs to
DOC_DIR := doc
DOC_PUB_RELEASE_PATH := $(DOC_PUB_PATH)/$(RELEASE)
ifndef VIRTUAL_ENV
$(error You must activate the neon virtual environment before continuing)
endif
.PHONY: env default install uninstall clean test style lint lint3k check doc
default: install
install:
@pip install -r requirements.txt
@pip install -e .
uninstall:
@pip uninstall -y ngraph
@pip uninstall -r requirements.txt
clean:
@find . -name "*.py[co]" -type f -delete
@find . -name "__pycache__" -type d -delete
@rm -f .coverage coverage.xml
@rm -rf ngraph.egg-info
@$(MAKE) -C $(DOC_DIR) clean
@echo
test:
@echo Running unit tests...
@py.test --cov=ngraph $(TEST_OPTS) $(TEST_DIRS)
@coverage xml
style:
flake8 $(STYLE_CHECK_OPTS) $(STYLE_CHECK_DIRS)
pylint --reports=n --output-format=colorized --py3k $(PYLINT3K_ARGS) --ignore=.venv *
lint:
pylint --output-format=colorized ngraph
lint3k:
pylint --py3k $(PYLINT3K_ARGS) --ignore=.venv *
check:
@echo "Running style checks. Number of style errors is... "
-@flake8 --count $(STYLE_CHECK_OPTS) $(STYLE_CHECK_DIRS) \
> /dev/null
@echo
@echo "Number of missing docstrings is..."
-@pylint --disable=all --enable=missing-docstring -r n \
ngraph | grep "^C" | wc -l
@echo
@echo "Running unit tests..."
[email protected] $(TEST_DIRS) | tail -1 | cut -f 2,3 -d ' '
@echo
fixstyle: autopep8
autopep8:
@autopep8 -a -a --global-config setup.cfg --in-place `find . -name \*.py`
@echo run "git diff" to see what may need to be checked in and "make style" to see what work remains
doc:
$(MAKE) -C $(DOC_DIR) clean
$(MAKE) -C $(DOC_DIR) html
@echo "Documentation built in $(DOC_DIR)/build/html"
@echo
publish_doc: doc
ifneq (,$(DOC_PUB_HOST))
@-cd $(DOC_DIR)/build/html && \
rsync -avz -essh --perms --chmod=ugo+rX . \
$(DOC_PUB_USER)@$(DOC_PUB_HOST):$(DOC_PUB_RELEASE_PATH)
@-ssh $(DOC_PUB_USER)@$(DOC_PUB_HOST) \
'rm -f $(DOC_PUB_PATH)/latest && \
ln -sf $(DOC_PUB_RELEASE_PATH) $(DOC_PUB_PATH)/latest'
else
@echo "Can't publish. Ensure DOC_PUB_HOST, DOC_PUB_USER, DOC_PUB_PATH set"
endif
release: check
@echo "Bump version number in setup.py"
@vi setup.py
@echo "Bump version number in doc/source/conf.py"
@vi doc/source/conf.py
@echo "Update ChangeLog"
@vi ChangeLog
@echo "TODO (manual steps): release on github and update docs with 'make publish_doc'"
@echo