From d6b8aa7dce415df9bddd76fd197222cda240ec1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asger=20Geel=20Weirs=C3=B8e?= Date: Sat, 5 Sep 2020 13:05:09 +0200 Subject: [PATCH] updates build script to remove old builds before uploading --- build.py | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/build.py b/build.py index e182691..a4d8720 100644 --- a/build.py +++ b/build.py @@ -1,35 +1,32 @@ import argparse import subprocess - +import pathlib +import os def main(): parser = argparse.ArgumentParser("Build script for pypi and pypi test") - group = parser.add_mutually_exclusive_group(required=True) - group.add_argument( - '--test', - action='store_true', - help='Build to test.pypi.org' - ) - group.add_argument( - '--re', - action='store_true', - help='Build to pypi.org' - ) - group.add_argument( - '--check', - action='store_true', - help='Displays the twine check for dist' - ) + group = parser.add_mutually_exclusive_group(required=True) + + group.add_argument('--test', action='store_true', help='Build to test.pypi.org') + group.add_argument('--pypi', action='store_true', help='Build to pypi.org') + group.add_argument('--check', action='store_true', help='Displays the twine check for dist') args = parser.parse_args() - subprocess.call(['rm', 'dist/*']) - subprocess.call(['python3', 'setup.py', 'sdist', 'bdist_wheel']) + + for path in pathlib.Path('dist').iterdir(): + os.remove(path) + + subprocess.call(['python3', 'setup.py', 'sdist', 'bdist_wheel'], stdout=subprocess.PIPE) + if args.test: subprocess.call(['twine', 'upload', '--config-file', '.pypirc', '--repository', 'testpypi', 'dist/*']) - elif args.re: + + elif args.pypi: subprocess.call(['twine', 'upload', '--config-file', '.pypirc', '--repository', 'pypi', 'dist/*']) + else: subprocess.call(['twine', 'check', 'dist/*']) + if __name__ == '__main__': main()