-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtasks.py
66 lines (48 loc) · 1.8 KB
/
tasks.py
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
# -*- encoding: utf-8 -*-
# ! python3
import shutil
import warnings
from invoke import task
PROJECT_NAME = 'tensorflow_serving_api_python3'
@task
def clean(ctx):
"""remove build artifacts"""
shutil.rmtree('{PROJECT_NAME}.egg-info'.format(PROJECT_NAME=PROJECT_NAME), ignore_errors=True)
shutil.rmtree('build', ignore_errors=True)
shutil.rmtree('dist', ignore_errors=True)
shutil.rmtree('htmlcov', ignore_errors=True)
shutil.rmtree('__pycache__', ignore_errors=True)
@task
def check(ctx):
"""Check setup"""
ctx.run("python setup.py --no-user-cfg --verbose check --metadata --restructuredtext --strict")
@task
def test_install(ctx):
"""try to install built package"""
ctx.run("pip uninstall {PROJECT_NAME} --yes".format(PROJECT_NAME=PROJECT_NAME), warn=True)
ctx.run("pip install --no-cache-dir --no-index --find-links=file:./dist {PROJECT_NAME}".format(PROJECT_NAME=PROJECT_NAME))
ctx.run("pip uninstall {PROJECT_NAME} --yes".format(PROJECT_NAME=PROJECT_NAME))
@task
def build(ctx):
"""build package"""
ctx.run("python setup.py build")
ctx.run("python setup.py sdist")
ctx.run("python setup.py bdist_wheel")
@task
def publish(ctx):
"""publish package"""
warnings.warn("Deprecated", DeprecationWarning, stacklevel=2)
check(ctx)
ctx.run('python setup.py sdist upload -r pypi') # Use python setup.py REGISTER
ctx.run('python setup.py bdist_wheel upload -r pypi')
@task
def publish_twine(ctx):
"""publish package"""
check(ctx)
ctx.run('twine upload dist/* --skip-existing')
@task
def publish_test(ctx):
"""publish package"""
check(ctx)
ctx.run('python setup.py sdist upload -r https://test.pypi.org/legacy/') # Use python setup.py REGISTER
ctx.run('python setup.py bdist_wheel upload -r https://test.pypi.org/legacy/')