Skip to content

Commit 30152d1

Browse files
authored
Awscrt 0.5.6 (#32)
* continuous delivery waits for pypi * latest awscrt
1 parent 8635538 commit 30152d1

File tree

5 files changed

+48
-4
lines changed

5 files changed

+48
-4
lines changed

continuous-delivery/publish_to_test_pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ phases:
1313
build:
1414
commands:
1515
- echo Build started on `date`
16-
- cd aws-iot-device-sdk-python-v2
16+
- cd aws-iot-device-sdk-python-v2
1717
- python3 setup.py sdist bdist_wheel --universal
1818
- python3 -m twine upload -r testpypi dist/*
1919
post_build:

continuous-delivery/test_prod_pypi.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ phases:
1717
build:
1818
commands:
1919
- echo Build started on `date`
20-
- cd aws-iot-device-sdk-python-v2
20+
- cd aws-iot-device-sdk-python-v2
2121
- CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv)
22+
- python3 continuous-delivery/wait-for-pypi.py awsiotsdk $CURRENT_TAG_VERSION --index https://pypi.python.org/pypi
2223
- python3 -m pip install --user awsiotsdk==$CURRENT_TAG_VERSION
2324
- python3 samples/basic_discovery.py --region us-east-1 --cert /tmp/certificate.pem --key /tmp/privatekey.pem --root-ca /tmp/AmazonRootCA1.pem --thing-name aws-sdk-crt-unit-test --print-discover-resp-only -v Trace
2425

continuous-delivery/test_test_pypi.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ phases:
1717
build:
1818
commands:
1919
- echo Build started on `date`
20-
- cd aws-iot-device-sdk-python-v2
20+
- cd aws-iot-device-sdk-python-v2
2121
- CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv)
2222
# this is here because typing isn't in testpypi, so pull it from prod instead
2323
- python3 -m pip install typing
24+
- python3 continuous-delivery/wait-for-pypi.py awsiotsdk $CURRENT_TAG_VERSION --index https://test.pypi.org/pypi
2425
- python3 -m pip install -i https://testpypi.python.org/simple --user awsiotsdk==$CURRENT_TAG_VERSION
2526
- python3 samples/basic_discovery.py --region us-east-1 --cert /tmp/certificate.pem --key /tmp/privatekey.pem --root-ca /tmp/AmazonRootCA1.pem --thing-name aws-sdk-crt-unit-test --print-discover-resp-only -v Trace
2627

continuous-delivery/wait-for-pypi.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import argparse
2+
import subprocess
3+
import sys
4+
import time
5+
6+
DEFAULT_TIMEOUT = 60 * 30 # 30 min
7+
DEFAULT_INTERVAL = 5
8+
DEFAULT_INDEX_URL = 'https://pypi.python.org/pypi'
9+
10+
11+
def wait(package, version, index_url=DEFAULT_INDEX_URL, timeout=DEFAULT_TIMEOUT, interval=DEFAULT_INTERVAL):
12+
give_up_time = time.time() + timeout
13+
while True:
14+
output = subprocess.check_output([sys.executable, '-m', 'pip', 'search', '--index', index_url, package])
15+
output = output.decode()
16+
17+
# output looks like: 'awscrt (0.3.1) - A common runtime for AWS Python projects\n...'
18+
if output.startswith('{} ({})'.format(package, version)):
19+
return True
20+
21+
if time.time() >= give_up_time:
22+
return False
23+
24+
time.sleep(interval)
25+
26+
27+
if __name__ == '__main__':
28+
parser = argparse.ArgumentParser()
29+
parser.add_argument('package', help="Packet name")
30+
parser.add_argument('version', help="Package version")
31+
parser.add_argument('--index', default=DEFAULT_INDEX_URL, metavar='<url>',
32+
help="Base URL of Python Package Index. (default {})".format(DEFAULT_INDEX_URL))
33+
parser.add_argument('--timeout', type=float, default=DEFAULT_TIMEOUT, metavar='<sec>',
34+
help="Give up after N seconds.")
35+
parser.add_argument('--interval', type=float, default=DEFAULT_INTERVAL, metavar='<sec>',
36+
help="Query PyPI every N seconds")
37+
args = parser.parse_args()
38+
39+
if wait(args.package, args.version, args.index, args.timeout, args.interval):
40+
print('{} {} is available in pypi'.format(args.package, args.version))
41+
else:
42+
exit("Timed out waiting for pypi to report {} {} as latest".format(args.package, args.version))

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
url='https://github.com/aws/aws-iot-device-sdk-python-v2',
2424
packages = ['awsiot'],
2525
install_requires=[
26-
'awscrt==0.5.5',
26+
'awscrt==0.5.6',
2727
'futures;python_version<"3.2"',
2828
'typing;python_version<"3.5"',
2929
],

0 commit comments

Comments
 (0)