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
|
# coding: utf-8
from __future__ import unicode_literals, division, absolute_import, print_function
import subprocess
import sys
import twine.cli
from . import package_name, package_root, has_tests_package
from .build import run as build
def run():
"""
Creates a sdist .tar.gz and a bdist_wheel --univeral .whl and uploads
them to pypi
:return:
A bool - if the packaging and upload process was successful
"""
git_wc_proc = subprocess.Popen(
['git', 'status', '--porcelain', '-uno'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
cwd=package_root
)
git_wc_status, _ = git_wc_proc.communicate()
if len(git_wc_status) > 0:
print(git_wc_status.decode('utf-8').rstrip(), file=sys.stderr)
print('Unable to perform release since working copy is not clean', file=sys.stderr)
return False
git_tag_proc = subprocess.Popen(
['git', 'tag', '-l', '--contains', 'HEAD'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=package_root
)
tag, tag_error = git_tag_proc.communicate()
if len(tag_error) > 0:
print(tag_error.decode('utf-8').rstrip(), file=sys.stderr)
print('Error looking for current git tag', file=sys.stderr)
return False
if len(tag) == 0:
print('No git tag found on HEAD', file=sys.stderr)
return False
tag = tag.decode('ascii').strip()
build()
twine.cli.dispatch(['upload', 'dist/%s-%s*' % (package_name, tag)])
if has_tests_package:
twine.cli.dispatch(['upload', 'dist/%s_tests-%s*' % (package_name, tag)])
return True
|