From 9f8fc42e7e774ae33a1c0ff60d8e6cf6c77610ee Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Thu, 17 Oct 2019 10:50:27 -0700 Subject: [PATCH] Fix wait-for-pypi script (#88) --- codebuild/cd/publish_to_prod_pypi.yml | 2 +- codebuild/cd/publish_to_test_pypi.yml | 2 +- continuous-delivery/wait-for-pypi.py | 17 ++++++++++------- setup.py | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/codebuild/cd/publish_to_prod_pypi.yml b/codebuild/cd/publish_to_prod_pypi.yml index ec5060564..e846ead45 100644 --- a/codebuild/cd/publish_to_prod_pypi.yml +++ b/codebuild/cd/publish_to_prod_pypi.yml @@ -22,7 +22,7 @@ phases: - CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv) - python3 continuous-delivery/pull-pypirc.py prod - python3 -m twine upload -r pypi ../dist/* - - python3 continuous-delivery/wait-for-pypi.py awscrt $CURRENT_TAG_VERSION --index-url https://pypi.org/simple + - python3 continuous-delivery/wait-for-pypi.py awscrt $CURRENT_TAG_VERSION --index https://pypi.python.org/pypi post_build: commands: - echo Build completed on `date` diff --git a/codebuild/cd/publish_to_test_pypi.yml b/codebuild/cd/publish_to_test_pypi.yml index c0515c972..7ab0033b8 100644 --- a/codebuild/cd/publish_to_test_pypi.yml +++ b/codebuild/cd/publish_to_test_pypi.yml @@ -22,7 +22,7 @@ phases: - CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv) - python3 continuous-delivery/pull-pypirc.py alpha - python3 -m twine upload -r testpypi ../dist/* - - python3 continuous-delivery/wait-for-pypi.py awscrt $CURRENT_TAG_VERSION --index-url https://testpypi.python.org/simple + - python3 continuous-delivery/wait-for-pypi.py awscrt $CURRENT_TAG_VERSION --index https://test.pypi.org/pypi post_build: commands: - echo Build completed on `date` diff --git a/continuous-delivery/wait-for-pypi.py b/continuous-delivery/wait-for-pypi.py index b51818762..3096ef225 100644 --- a/continuous-delivery/wait-for-pypi.py +++ b/continuous-delivery/wait-for-pypi.py @@ -3,15 +3,15 @@ import sys import time -DEFAULT_TIMEOUT = 1800 +DEFAULT_TIMEOUT = 60 * 30 # 30 min DEFAULT_INTERVAL = 5 -DEFAULT_INDEX_URL = 'https://pypi.org/simple' +DEFAULT_INDEX_URL = 'https://pypi.python.org/pypi' def wait(package, version, index_url=DEFAULT_INDEX_URL, timeout=DEFAULT_TIMEOUT, interval=DEFAULT_INTERVAL): give_up_time = time.time() + timeout while True: - output = subprocess.check_output([sys.executable, '-m', 'pip', '--index', index_url, 'search', package]) + output = subprocess.check_output([sys.executable, '-m', 'pip', 'search', '--index', index_url, package]) output = output.decode() # output looks like: 'awscrt (0.3.1) - A common runtime for AWS Python projects\n...' @@ -28,12 +28,15 @@ def wait(package, version, index_url=DEFAULT_INDEX_URL, timeout=DEFAULT_TIMEOUT, parser = argparse.ArgumentParser() parser.add_argument('package', help="Packet name") parser.add_argument('version', help="Package version") - parser.add_argument('-i', '--index-url', default=DEFAULT_INDEX_URL, help="PyPI URL") - parser.add_argument('--timeout', type=float, default=DEFAULT_TIMEOUT, help="Give up after N seconds.") - parser.add_argument('--interval', type=float, default=DEFAULT_INTERVAL, help="Query PyPI every N seconds") + parser.add_argument('--index', default=DEFAULT_INDEX_URL, metavar='', + help="Base URL of Python Package Index. (default {})".format(DEFAULT_INDEX_URL)) + parser.add_argument('--timeout', type=float, default=DEFAULT_TIMEOUT, metavar='', + help="Give up after N seconds.") + parser.add_argument('--interval', type=float, default=DEFAULT_INTERVAL, metavar='', + help="Query PyPI every N seconds") args = parser.parse_args() - if wait(args.package, args.version, args.index_url, args.timeout, args.interval): + if wait(args.package, args.version, args.index, args.timeout, args.interval): print('{} {} is available in pypi'.format(args.package, args.version)) else: exit("Timed out waiting for pypi to report {} {} as latest".format(args.package, args.version)) diff --git a/setup.py b/setup.py index d59001aa3..e547cf713 100644 --- a/setup.py +++ b/setup.py @@ -241,7 +241,7 @@ def awscrt_ext(): setuptools.setup( name="awscrt", - version="0.3.2", + version="0.3.3", author="Amazon Web Services, Inc", author_email="aws-sdk-common-runtime@amazon.com", description="A common runtime for AWS Python projects",