Skip to content

Commit c12b888

Browse files
committed
add tasks
1 parent 7464a6e commit c12b888

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

requirements/dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ wheel>=0.29.0
55
setuptools>=35.0.2
66
docutils>=0.13.1
77
pygments>=2.1.3
8-
invoke==0.12.2
8+
invoke
99
twine

tasks.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# -*- encoding: utf-8 -*-
2+
# ! python3
3+
4+
import shutil
5+
import warnings
6+
7+
from invoke import task
8+
9+
PROJECT_NAME = 'tensorflow_serving_api_python3'
10+
11+
12+
@task
13+
def clean(ctx):
14+
"""remove build artifacts"""
15+
shutil.rmtree('{PROJECT_NAME}.egg-info'.format(PROJECT_NAME=PROJECT_NAME), ignore_errors=True)
16+
shutil.rmtree('build', ignore_errors=True)
17+
shutil.rmtree('dist', ignore_errors=True)
18+
shutil.rmtree('htmlcov', ignore_errors=True)
19+
shutil.rmtree('__pycache__', ignore_errors=True)
20+
21+
22+
@task
23+
def check(ctx):
24+
"""Check setup"""
25+
ctx.run("python setup.py --no-user-cfg --verbose check --metadata --restructuredtext --strict")
26+
27+
28+
@task
29+
def test_install(ctx):
30+
"""try to install built package"""
31+
ctx.run("pip uninstall {PROJECT_NAME} --yes".format(PROJECT_NAME=PROJECT_NAME), warn=True)
32+
ctx.run("pip install --use-wheel --no-cache-dir --no-index --find-links=file:./dist {PROJECT_NAME}".format(PROJECT_NAME=PROJECT_NAME))
33+
ctx.run("pip uninstall {PROJECT_NAME} --yes".format(PROJECT_NAME=PROJECT_NAME))
34+
35+
36+
@task
37+
def build(ctx):
38+
"""build package"""
39+
ctx.run("python setup.py build")
40+
ctx.run("python setup.py sdist")
41+
ctx.run("python setup.py bdist_wheel")
42+
43+
44+
@task
45+
def publish(ctx):
46+
"""publish package"""
47+
warnings.warn("Deprecated", DeprecationWarning, stacklevel=2)
48+
49+
check(ctx)
50+
ctx.run('python setup.py sdist upload -r pypi') # Use python setup.py REGISTER
51+
ctx.run('python setup.py bdist_wheel upload -r pypi')
52+
53+
54+
@task
55+
def publish_twine(ctx):
56+
"""publish package"""
57+
check(ctx)
58+
ctx.run('twine upload dist/* --skip-existing')
59+
60+
61+
@task
62+
def publish_test(ctx):
63+
"""publish package"""
64+
check(ctx)
65+
ctx.run('python setup.py sdist upload -r https://test.pypi.org/legacy/') # Use python setup.py REGISTER
66+
ctx.run('python setup.py bdist_wheel upload -r https://test.pypi.org/legacy/')

0 commit comments

Comments
 (0)