|
| 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