-
Notifications
You must be signed in to change notification settings - Fork 51
/
Makefile
125 lines (101 loc) · 4.16 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
# Copyright (c) 2022-2024, NVIDIA CORPORATION. All rights reserved.
#
# 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.
.PHONY: clean clean-build clean-tritonserver clean-pyc clean-docs clean-test docs lint test coverage release dist build-triton extract-triton install install-dev help
.DEFAULT_GOAL := help
define BROWSER_PYSCRIPT
import os, webbrowser, sys
from urllib.request import pathname2url
webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
endef
export BROWSER_PYSCRIPT
define PRINT_HELP_PYSCRIPT
import re, sys
for line in sys.stdin:
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
if match:
target, help = match.groups()
print("%-20s %s" % (target, help))
endef
export PRINT_HELP_PYSCRIPT
BROWSER := python -c "$$BROWSER_PYSCRIPT"
PIP_INSTALL := pip install --extra-index-url https://pypi.ngc.nvidia.com
TEST_CONTAINER_VERSION ?= 24.09
TRITONSERVER_IMAGE_VERSION ?= 24.09
TRITONSERVER_IMAGE_NAME = nvcr.io/nvidia/tritonserver:$(TRITONSERVER_IMAGE_VERSION)-pyt-python-py3
TRITONSERVER_OUTPUT_DIR = ${PWD}/pytriton/tritonserver
TRITONSERVER_BASENAME = pytriton
PYTRITON_IMAGE_NAME = $(TRITONSERVER_BASENAME):$(TEST_CONTAINER_VERSION)
# to set PLATFORM from outside, use: make PLATFORM=linux/arm64;
# correct values are: linux/amd64 (default), linux/arm64
PLATFORM=linux/amd64
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
clean: clean-build clean-pyc clean-test clean-tritonserver clean-docs ## remove all build, tritonserver, test, docs, coverage and Python artifacts
clean-build: ## remove build artifacts
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +
clean-tritonserver:
rm -fr pytriton/tritonserver
clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
clean-docs: ## remove test and coverage artifacts
rm -rf site
clean-test: ## remove test and coverage artifacts
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/
rm -fr .pytest_cache
rm -fr .pytype/
docs: clean-docs ## generate site
cp CHANGELOG.md docs
cp CONTRIBUTING.md docs
cp LICENSE docs/LICENSE.md
cp examples/README.md docs/examples.md
mkdocs build --clean
docs-serve: docs
mkdocs serve
lint: ## check style with pre-commit and pytype
tox -e pre-commit,pytype --develop
test: ## run tests on every Python version with tox
tox --develop --skip-missing-interpreters
coverage: ## check code coverage quickly with the default Python
coverage run --source pytriton -m pytest
coverage report -m
coverage html
$(BROWSER) htmlcov/index.html
dist: clean build-triton extract-triton ## builds source and wheel package
bash ./scripts/build_wheel.sh $(PLATFORM)
ls -lh dist
find ./dist -iname *-linux*.whl -type f -exec bash ./scripts/add_libs_to_wheel.sh $(PYTRITON_IMAGE_NAME) $(TRITONSERVER_OUTPUT_DIR) {} $(PLATFORM) \;
find ./dist -iname *-linux*.whl -type f -delete
ls -lh dist
twine check dist/*
build-triton: ## build Triton with Python Stubs
bash ./scripts/build_triton.sh $(TRITONSERVER_IMAGE_NAME) $(PYTRITON_IMAGE_NAME) $(PLATFORM)
echo "export PYTRITON_IMAGE_NAME=$(PYTRITON_IMAGE_NAME)" > .env
extract-triton: build-triton ## extract Triton binaries and libraries
# changing dst path, change also in clean-build and pyproject.toml
bash ./scripts/extract_triton.sh $(PYTRITON_IMAGE_NAME) $(TRITONSERVER_OUTPUT_DIR) $(PLATFORM)
install: clean extract-triton ## install the package to the active Python's site-packages
$(PIP_INSTALL) --upgrade pip
$(PIP_INSTALL) .
install-dev: clean-build clean-pyc
$(PIP_INSTALL) --upgrade pip
$(PIP_INSTALL) -e .[dev]