diff options
Diffstat (limited to 'scripts/dev/build_release.py')
-rwxr-xr-x | scripts/dev/build_release.py | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/scripts/dev/build_release.py b/scripts/dev/build_release.py index 2b3aff4b4..5463441be 100755 --- a/scripts/dev/build_release.py +++ b/scripts/dev/build_release.py @@ -26,6 +26,7 @@ import os.path import sys import time import shutil +import pathlib import plistlib import subprocess import argparse @@ -480,14 +481,17 @@ def build_sdist(): """Build an sdist and list the contents.""" utils.print_title("Building sdist") - _maybe_remove('dist') + dist_path = pathlib.Path('dist') + _maybe_remove(dist_path) - subprocess.run([sys.executable, 'setup.py', 'sdist'], check=True) - dist_files = os.listdir(os.path.abspath('dist')) - assert len(dist_files) == 1 + subprocess.run([sys.executable, '-m', 'build'], check=True) - dist_file = os.path.join('dist', dist_files[0]) - subprocess.run(['gpg', '--detach-sign', '-a', dist_file], check=True) + dist_files = list(dist_path.glob('*.tar.gz')) + filename = 'qutebrowser-{}.tar.gz'.format(qutebrowser.__version__) + assert dist_files == [dist_path / filename], dist_files + dist_file = dist_files[0] + + subprocess.run(['gpg', '--detach-sign', '-a', str(dist_file)], check=True) by_ext = collections.defaultdict(list) @@ -507,11 +511,13 @@ def build_sdist(): utils.print_subtitle(ext) print('\n'.join(files)) - filename = 'qutebrowser-{}.tar.gz'.format(qutebrowser.__version__) artifacts = [ - (os.path.join('dist', filename), 'application/gzip', 'Source release'), - (os.path.join('dist', filename + '.asc'), 'application/pgp-signature', - 'Source release - PGP signature'), + (str(dist_file), 'application/gzip', 'Source release'), + ( + str(dist_file.with_suffix(dist_file.suffix + '.asc')), + 'application/pgp-signature', + 'Source release - PGP signature', + ), ] return artifacts @@ -600,15 +606,19 @@ def github_upload(artifacts, tag, gh_token): def pypi_upload(artifacts): """Upload the given artifacts to PyPI using twine.""" utils.print_title("Uploading to PyPI...") - filenames = [a[0] for a in artifacts] - subprocess.run([sys.executable, '-m', 'twine', 'upload'] + filenames, - check=True) + run_twine('upload', artifacts) -def upgrade_sdist_dependencies(): - """Make sure we have the latest tools for an sdist release.""" - subprocess.run([sys.executable, '-m', 'pip', 'install', '-U', 'twine', - 'pip', 'wheel', 'setuptools'], check=True) +def twine_check(artifacts): + """Check packages using 'twine check'.""" + utils.print_title("Running twine check...") + run_twine('check', artifacts, '--strict') + + +def run_twine(command, artifacts, *args): + filenames = [a[0] for a in artifacts] + subprocess.run([sys.executable, '-m', 'twine', command] + list(args) + filenames, + check=True) def main(): @@ -668,9 +678,9 @@ def main(): elif sys.platform == 'darwin': artifacts = build_mac(gh_token=gh_token, debug=args.debug) else: - upgrade_sdist_dependencies() test_makefile() artifacts = build_sdist() + twine_check(artifacts) upload_to_pypi = True if args.upload: |