blob: 196da746a109fc7011acb9ed6b68d70712611a29 [file] [log] [blame]
Chip Boling67b674a2019-02-08 11:42:18 -06001# Copyright 2018 the original author or authors.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
Matt Jeanneretf3ad6852019-02-08 18:21:44 -050014
Zack Williamsa95e2c82019-04-17 15:43:54 -070015# Configure shell
16SHELL = bash -eu -o pipefail
Matt Jeanneretf3ad6852019-02-08 18:21:44 -050017
Zack Williamsa95e2c82019-04-17 15:43:54 -070018default: help
Chip Boling67b674a2019-02-08 11:42:18 -060019
20# This should to be the first and default target in this Makefile
21help:
22 @echo "Usage: make [<target>]"
23 @echo "where available targets are:"
24 @echo
Matt Jeanneretf3ad6852019-02-08 18:21:44 -050025 @echo "clean : Remove files created by the build and tests"
Zack Williamsa95e2c82019-04-17 15:43:54 -070026 @echo "dist : Create source distribution of the python package"
Matt Jeanneretf3ad6852019-02-08 18:21:44 -050027 @echo "help : Print this help"
Zack Williamsa95e2c82019-04-17 15:43:54 -070028 @echo "test : Run all unit test"
29 @echo "upload : Upload test version of python package to test.pypi.org"
Chip Boling67b674a2019-02-08 11:42:18 -060030 @echo
31
Zack Williamsa95e2c82019-04-17 15:43:54 -070032# ignore these directories
33.PHONY: test dist
Chip Boling67b674a2019-02-08 11:42:18 -060034
Matteo Scandoloe3c84462020-03-30 15:26:00 -070035local-protos:
36 mkdir -p local_imports
37ifdef LOCAL_PROTOS
38 mkdir -p local_imports/voltha-protos/dist
39 rm -f local_imports/voltha-protos/dist/*.tar.gz
40 cp ${LOCAL_PROTOS}/dist/*.tar.gz local_imports/voltha-protos/dist/
41endif
42
Zack Williamsa95e2c82019-04-17 15:43:54 -070043dist:
44 @ echo "Creating python source distribution"
William Kurkian3b144f12019-06-11 20:36:15 -040045 rm -rf dist/
Chip Boling67b674a2019-02-08 11:42:18 -060046 python setup.py sdist
47
48upload: dist
Zack Williamsa95e2c82019-04-17 15:43:54 -070049 @ echo "Uploading sdist to test.pypi.org"
Chip Boling67b674a2019-02-08 11:42:18 -060050 twine upload --repository-url https://test.pypi.org/legacy/ dist/*
Chip Boling67b674a2019-02-08 11:42:18 -060051
Matt Jeanneret6a7950c2019-09-17 11:14:33 -040052VENVDIR := venv-pyvoltha
53
Matteo Scandoloe3c84462020-03-30 15:26:00 -070054venv: local-protos
Zack Williams84a71e92019-11-15 09:00:19 -070055 virtualenv --python=python3.6 ${VENVDIR};\
56 source ./${VENVDIR}/bin/activate ; set -u ;\
57 pip install -r requirements.txt
Matteo Scandoloe3c84462020-03-30 15:26:00 -070058ifdef LOCAL_PROTOS
59 source ./${VENVDIR}/bin/activate ; set -u ;\
60 pip install local_imports/voltha-protos/dist/*.tar.gz
61endif
Matt Jeanneret6a7950c2019-09-17 11:14:33 -040062
Zack Williamsa95e2c82019-04-17 15:43:54 -070063test:
64 @ echo "Executing unit tests w/tox"
65 tox
Chip Boling67b674a2019-02-08 11:42:18 -060066
67clean:
68 find . -name '*.pyc' | xargs rm -f
Matt Jeanneretc233b2e2019-12-07 15:46:11 -050069 find . -name '__pycache__' | xargs rm -rf
Zack Williamsa95e2c82019-04-17 15:43:54 -070070 rm -rf \
71 .tox \
Zack Williams84a71e92019-11-15 09:00:19 -070072 .coverage \
Zack Williamsa95e2c82019-04-17 15:43:54 -070073 coverage.xml \
74 dist \
75 nose-results.xml \
76 pyvoltha.egg-info \
Matt Jeanneret6a7950c2019-09-17 11:14:33 -040077 test/unit/tmp \
78 rm -rf ${VENVDIR}
79
80# end file