From 1af9d9b58fbdf1a8fcb272fc510a750a3db06f13 Mon Sep 17 00:00:00 2001 From: Laurent Bachelier Date: Sun, 23 Dec 2018 20:00:22 +0100 Subject: [PATCH] release: Use setuptools to make the tarball --- release.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ release.sh | 5 +---- 2 files changed, 48 insertions(+), 4 deletions(-) create mode 100755 release.py diff --git a/release.py b/release.py new file mode 100755 index 0000000000..576dd31ed4 --- /dev/null +++ b/release.py @@ -0,0 +1,47 @@ +#!/usr/bin/python +from __future__ import print_function + +import argparse +import os +import sys +from subprocess import check_call + +WORKTREE = 'release_tmp' +OPTIONS = ['--qt', '--xdg'] + +def make_tarball(tag): + # Create and enter a temporary worktree + if os.path.isdir(WORKTREE): + check_call(['git', 'worktree', 'remove', '--force', WORKTREE]) + check_call(['git', 'worktree', 'add', WORKTREE, tag]) + assert os.path.isdir(WORKTREE) + os.chdir(WORKTREE) + + check_call([sys.executable, 'setup.py'] + OPTIONS + ['sdist', + '--keep', + '--dist-dir', '../dist']) + + # Clean up the temporary worktree + os.chdir(os.pardir) + check_call(['git', 'worktree', 'remove', '--force', WORKTREE]) + assert not os.path.isdir(WORKTREE) + + tarball = 'dist/weboob-%s.tar.gz' % tag + if os.path.exists(tarball): + print('Generated tarball: %s' % tarball) + print('To upload to PyPI, run: twine upload -s %s' % tarball) + else: + raise Exception('Generated tarball not found at %s' % tarball) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers() + + tarball_parser = subparsers.add_parser('tarball') + tarball_parser.add_argument('tag') + tarball_parser.set_defaults(mode='tarball') + + args = parser.parse_args() + if args.mode == 'tarball': + make_tarball(args.tag) diff --git a/release.sh b/release.sh index b2fbabe005..67e8d2c6a7 100755 --- a/release.sh +++ b/release.sh @@ -49,10 +49,7 @@ echo "Release tag:" git tag $VERSION -s -m "Weboob $VERSION" echo -ne "\n" -echo -n "Generating archive.. " -git archive HEAD --prefix=weboob-$VERSION/ -o weboob-$VERSION.tar -gzip -f weboob-$VERSION.tar -md5sum weboob-$VERSION.tar.gz +python release.py tarball $VERSION echo -ne "\nDo you want to change the version number (y/n) " read change_version -- GitLab