Chip Boling | 67b674a | 2019-02-08 11:42:18 -0600 | [diff] [blame] | 1 | # 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 Jeanneret | f3ad685 | 2019-02-08 18:21:44 -0500 | [diff] [blame] | 14 | |
Zack Williams | a95e2c8 | 2019-04-17 15:43:54 -0700 | [diff] [blame] | 15 | # Configure shell |
| 16 | SHELL = bash -eu -o pipefail |
Matt Jeanneret | f3ad685 | 2019-02-08 18:21:44 -0500 | [diff] [blame] | 17 | |
Zack Williams | a95e2c8 | 2019-04-17 15:43:54 -0700 | [diff] [blame] | 18 | default: help |
Chip Boling | 67b674a | 2019-02-08 11:42:18 -0600 | [diff] [blame] | 19 | |
| 20 | # This should to be the first and default target in this Makefile |
| 21 | help: |
| 22 | @echo "Usage: make [<target>]" |
| 23 | @echo "where available targets are:" |
| 24 | @echo |
Matt Jeanneret | f3ad685 | 2019-02-08 18:21:44 -0500 | [diff] [blame] | 25 | @echo "clean : Remove files created by the build and tests" |
Zack Williams | a95e2c8 | 2019-04-17 15:43:54 -0700 | [diff] [blame] | 26 | @echo "dist : Create source distribution of the python package" |
Matt Jeanneret | f3ad685 | 2019-02-08 18:21:44 -0500 | [diff] [blame] | 27 | @echo "help : Print this help" |
Zack Williams | a95e2c8 | 2019-04-17 15:43:54 -0700 | [diff] [blame] | 28 | @echo "test : Run all unit test" |
| 29 | @echo "upload : Upload test version of python package to test.pypi.org" |
Chip Boling | 67b674a | 2019-02-08 11:42:18 -0600 | [diff] [blame] | 30 | @echo |
| 31 | |
Zack Williams | a95e2c8 | 2019-04-17 15:43:54 -0700 | [diff] [blame] | 32 | # ignore these directories |
| 33 | .PHONY: test dist |
Chip Boling | 67b674a | 2019-02-08 11:42:18 -0600 | [diff] [blame] | 34 | |
Matteo Scandolo | e3c8446 | 2020-03-30 15:26:00 -0700 | [diff] [blame] | 35 | local-protos: |
| 36 | mkdir -p local_imports |
| 37 | ifdef 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/ |
| 41 | endif |
| 42 | |
Zack Williams | a95e2c8 | 2019-04-17 15:43:54 -0700 | [diff] [blame] | 43 | dist: |
| 44 | @ echo "Creating python source distribution" |
William Kurkian | 3b144f1 | 2019-06-11 20:36:15 -0400 | [diff] [blame] | 45 | rm -rf dist/ |
Chip Boling | 67b674a | 2019-02-08 11:42:18 -0600 | [diff] [blame] | 46 | python setup.py sdist |
| 47 | |
| 48 | upload: dist |
Zack Williams | a95e2c8 | 2019-04-17 15:43:54 -0700 | [diff] [blame] | 49 | @ echo "Uploading sdist to test.pypi.org" |
Chip Boling | 67b674a | 2019-02-08 11:42:18 -0600 | [diff] [blame] | 50 | twine upload --repository-url https://test.pypi.org/legacy/ dist/* |
Chip Boling | 67b674a | 2019-02-08 11:42:18 -0600 | [diff] [blame] | 51 | |
Matt Jeanneret | 6a7950c | 2019-09-17 11:14:33 -0400 | [diff] [blame] | 52 | VENVDIR := venv-pyvoltha |
| 53 | |
Matteo Scandolo | e3c8446 | 2020-03-30 15:26:00 -0700 | [diff] [blame] | 54 | venv: local-protos |
Zack Williams | 84a71e9 | 2019-11-15 09:00:19 -0700 | [diff] [blame] | 55 | virtualenv --python=python3.6 ${VENVDIR};\ |
| 56 | source ./${VENVDIR}/bin/activate ; set -u ;\ |
| 57 | pip install -r requirements.txt |
Matteo Scandolo | e3c8446 | 2020-03-30 15:26:00 -0700 | [diff] [blame] | 58 | ifdef LOCAL_PROTOS |
| 59 | source ./${VENVDIR}/bin/activate ; set -u ;\ |
| 60 | pip install local_imports/voltha-protos/dist/*.tar.gz |
| 61 | endif |
Matt Jeanneret | 6a7950c | 2019-09-17 11:14:33 -0400 | [diff] [blame] | 62 | |
Zack Williams | a95e2c8 | 2019-04-17 15:43:54 -0700 | [diff] [blame] | 63 | test: |
| 64 | @ echo "Executing unit tests w/tox" |
| 65 | tox |
Chip Boling | 67b674a | 2019-02-08 11:42:18 -0600 | [diff] [blame] | 66 | |
| 67 | clean: |
| 68 | find . -name '*.pyc' | xargs rm -f |
Matt Jeanneret | c233b2e | 2019-12-07 15:46:11 -0500 | [diff] [blame] | 69 | find . -name '__pycache__' | xargs rm -rf |
Zack Williams | a95e2c8 | 2019-04-17 15:43:54 -0700 | [diff] [blame] | 70 | rm -rf \ |
| 71 | .tox \ |
Zack Williams | 84a71e9 | 2019-11-15 09:00:19 -0700 | [diff] [blame] | 72 | .coverage \ |
Zack Williams | a95e2c8 | 2019-04-17 15:43:54 -0700 | [diff] [blame] | 73 | coverage.xml \ |
| 74 | dist \ |
| 75 | nose-results.xml \ |
| 76 | pyvoltha.egg-info \ |
Matt Jeanneret | 6a7950c | 2019-09-17 11:14:33 -0400 | [diff] [blame] | 77 | test/unit/tmp \ |
| 78 | rm -rf ${VENVDIR} |
| 79 | |
| 80 | # end file |