From a580079206b5e84801eb6c195264ac61f93962bd Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 3 Dec 2021 15:28:04 +0100 Subject: scripts: Handle packaging dependencies via tox --- misc/requirements/requirements-dev.txt | 21 ++++++++++++++++++++- misc/requirements/requirements-dev.txt-raw | 2 ++ scripts/dev/build_release.py | 7 ------- scripts/dev/recompile_requirements.py | 11 +++++++++++ 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/misc/requirements/requirements-dev.txt b/misc/requirements/requirements-dev.txt index 0dd45cebc..126924092 100644 --- a/misc/requirements/requirements-dev.txt +++ b/misc/requirements/requirements-dev.txt @@ -1,26 +1,45 @@ # This file is automatically generated by scripts/dev/recompile_requirements.py +bleach==4.1.0 +build==0.7.0 bump2version==1.0.1 certifi==2021.10.8 cffi==1.15.0 charset-normalizer==2.0.8 +colorama==0.4.4 cryptography==36.0.0 Deprecated==1.2.13 +docutils==0.18.1 github3.py==3.0.0 hunter==3.3.8 idna==3.3 +importlib-metadata==4.8.2 +jeepney==0.7.1 jwcrypto==1.0 +keyring==23.4.0 manhole==1.8.0 packaging==21.3 +pep517==0.12.0 +pkginfo==1.8.2 pycparser==2.21 +Pygments==2.10.0 Pympler==0.9 pyparsing==3.0.6 PyQt-builder==1.12.2 python-dateutil==2.8.2 +readme-renderer==30.0 requests==2.26.0 -sip==6.4.0 +requests-toolbelt==0.9.1 +rfc3986==1.5.0 +SecretStorage==3.3.1 +sip==6.5.0 six==1.16.0 toml==0.10.2 +tomli==1.2.2 +tqdm==4.62.3 +twine==3.7.0 uritemplate==4.1.1 # urllib3==1.26.7 +webencodings==0.5.1 wrapt==1.13.3 +zipp==3.6.0 diff --git a/misc/requirements/requirements-dev.txt-raw b/misc/requirements/requirements-dev.txt-raw index fd840bab1..261f4459f 100644 --- a/misc/requirements/requirements-dev.txt-raw +++ b/misc/requirements/requirements-dev.txt-raw @@ -4,6 +4,8 @@ github3.py bump2version requests pyqt-builder +build +twine # Already included via test requirements #@ ignore: urllib3 diff --git a/scripts/dev/build_release.py b/scripts/dev/build_release.py index 2b3aff4b4..ddad1b607 100755 --- a/scripts/dev/build_release.py +++ b/scripts/dev/build_release.py @@ -605,12 +605,6 @@ def pypi_upload(artifacts): check=True) -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 main(): parser = argparse.ArgumentParser() parser.add_argument('--skip-docs', action='store_true', @@ -668,7 +662,6 @@ 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() upload_to_pypi = True diff --git a/scripts/dev/recompile_requirements.py b/scripts/dev/recompile_requirements.py index 1b9759eb8..ddda66a29 100644 --- a/scripts/dev/recompile_requirements.py +++ b/scripts/dev/recompile_requirements.py @@ -190,6 +190,17 @@ CHANGELOG_URLS = { 'future': 'https://python-future.org/whatsnew.html', 'pefile': 'https://github.com/erocarrera/pefile/commits/master', 'Deprecated': 'https://github.com/tantale/deprecated/blob/master/CHANGELOG.rst', + 'SecretStorage': 'https://github.com/mitya57/secretstorage/blob/master/changelog', + 'bleach': 'https://github.com/mozilla/bleach/blob/main/CHANGES', + 'jeepney': 'https://gitlab.com/takluyver/jeepney/-/blob/master/docs/release-notes.rst', + 'keyring': 'https://github.com/jaraco/keyring/blob/main/CHANGES.rst', + 'pkginfo': 'https://bazaar.launchpad.net/~tseaver/pkginfo/trunk/view/head:/CHANGES.txt', + 'readme-renderer': 'https://github.com/pypa/readme_renderer/blob/main/CHANGES.rst', + 'requests-toolbelt': 'https://github.com/requests/toolbelt/blob/master/HISTORY.rst', + 'rfc3986': 'https://rfc3986.readthedocs.io/en/latest/release-notes/index.html', + 'tqdm': 'https://tqdm.github.io/releases/', + 'twine': 'https://twine.readthedocs.io/en/stable/changelog.html', + 'webencodings': 'https://github.com/gsnedders/python-webencodings/commits/master', } -- cgit v1.2.3-54-g00ecf From 733868ff875a4a284cef77bd3e013d69ebef3c3e Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 3 Dec 2021 15:32:38 +0100 Subject: scripts: Run 'twine check' --- scripts/dev/build_release.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/dev/build_release.py b/scripts/dev/build_release.py index ddad1b607..d82c162b0 100755 --- a/scripts/dev/build_release.py +++ b/scripts/dev/build_release.py @@ -600,8 +600,18 @@ 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...") + run_twine('upload', artifacts) + + +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', 'upload'] + filenames, + subprocess.run([sys.executable, '-m', 'twine', command] + list(args) + filenames, check=True) @@ -664,6 +674,7 @@ def main(): else: test_makefile() artifacts = build_sdist() + twine_check(artifacts) upload_to_pypi = True if args.upload: -- cgit v1.2.3-54-g00ecf From 2378ba7886558436254a8cdd3a455b91bcfc6c8a Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 3 Dec 2021 15:52:03 +0100 Subject: scripts: Use 'build' to build sdist See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html --- scripts/dev/build_release.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/scripts/dev/build_release.py b/scripts/dev/build_release.py index d82c162b0..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 -- cgit v1.2.3-54-g00ecf