Skip to content

Commit

Permalink
Fix wait-for-pypi script (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
graebm authored Oct 17, 2019
1 parent 0ffa99c commit 9f8fc42
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion codebuild/cd/publish_to_prod_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion codebuild/cd/publish_to_test_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
17 changes: 10 additions & 7 deletions continuous-delivery/wait-for-pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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...'
Expand All @@ -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='<url>',
help="Base URL of Python Package Index. (default {})".format(DEFAULT_INDEX_URL))
parser.add_argument('--timeout', type=float, default=DEFAULT_TIMEOUT, metavar='<sec>',
help="Give up after N seconds.")
parser.add_argument('--interval', type=float, default=DEFAULT_INTERVAL, metavar='<sec>',
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))
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]",
description="A common runtime for AWS Python projects",
Expand Down

0 comments on commit 9f8fc42

Please sign in to comment.