diff --git a/NOTICE b/NOTICE index 27d390e9..e39345ce 100644 --- a/NOTICE +++ b/NOTICE @@ -1,3 +1,3 @@ -AWS IoT SDK for Python v2 -Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +AWS IoT Device SDK v2 for Python +Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0. diff --git a/README.md b/README.md index c15ab96b..ccdfe783 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# AWS IoT Device SDK for Python v2 -This document provides information about the AWS IoT device SDK for Python V2. +# AWS IoT Device SDK v2 for Python +This document provides information about the AWS IoT Device SDK v2 for Python. If you have any issues or feature requests, please file an issue or pull request. @@ -35,17 +35,18 @@ to Python by the `awscrt` package ([PyPI](https://pypi.org/project/awscrt/)) ([G ### Install from PyPI ``` -pip install awsiotsdk +python3 -m pip install awsiotsdk ``` ### Install from source ``` -pip install ./aws-iot-device-sdk-python-v2 +git clone https://github.com/aws/aws-iot-device-sdk-python-v2.git +python3 -m pip install ./aws-iot-device-sdk-python-v2 ``` ### Installation Issues -`awsiotsdk` depends on [awscrt](https://github.com/awslabs/aws-crt-python), which makes use of C extensions. Precompiled wheels are downloaded when installing on major platforms (Mac, Windows, Linux, Raspbian (python3 only)). If wheels are unavailable for your platform (ex: Raspbian with python2.7), your machine must compile some C libraries. If you encounter issues, install the following and try again: +`awsiotsdk` depends on [awscrt](https://github.com/awslabs/aws-crt-python), which makes use of C extensions. Precompiled wheels are downloaded when installing on major platforms (Mac, Windows, Linux, Raspbian. If wheels are unavailable for your platform, your machine must compile some C libraries. If you encounter issues, install the following and try again: ``` sudo apt-get update @@ -53,8 +54,6 @@ sudo apt-get install cmake sudo apt-get install libssl-dev ``` - - ## Mac-Only TLS Behavior Please note that on Mac, once a private key is used with a certificate, that certificate-key pair is imported into the Mac Keychain. All subsequent uses of that certificate will use the stored private key and ignore anything passed in programmatically. Beginning in v1.3.2, when a stored private key from the Keychain is used, the following will be logged at the "info" log level: diff --git a/awsiot/__init__.py b/awsiot/__init__.py index 14aede8c..76fe8542 100644 --- a/awsiot/__init__.py +++ b/awsiot/__init__.py @@ -19,7 +19,7 @@ PayloadObj = Dict[str, Any] PayloadToClassFn = Callable[[PayloadObj], T] -class MqttServiceClient(object): +class MqttServiceClient: """ Base class for an AWS MQTT Service Client """ @@ -153,7 +153,7 @@ def callback_wrapper(topic, payload, **kwargs): return future, topic -class ModeledClass(object): +class ModeledClass: """ Base for input/output classes generated from an AWS service model. """ diff --git a/awsiot/greengrass_discovery.py b/awsiot/greengrass_discovery.py index bba3788a..9792612e 100644 --- a/awsiot/greengrass_discovery.py +++ b/awsiot/greengrass_discovery.py @@ -7,7 +7,7 @@ from concurrent.futures import Future import json -class DiscoveryClient(object): +class DiscoveryClient: __slots__ = ['_bootstrap', '_tls_context', '_socket_options', '_region', '_tls_connection_options', '_gg_server_name', 'gg_url', 'port'] def __init__(self, bootstrap, socket_options, tls_context, region): @@ -63,7 +63,7 @@ def on_connection_completed(conn_future): http_stream = connection.request( request=request, on_body=on_incoming_body) - + http_stream.activate() http_stream.completion_future.add_done_callback(on_request_complete) diff --git a/builder.json b/builder.json index 58aff496..4d98f7e7 100644 --- a/builder.json +++ b/builder.json @@ -23,6 +23,11 @@ }, "manylinux": { "post_build_steps": [ + ["echo", "------ Python 3.7 ------"], + ["/opt/python/cp37-cp37m/bin/python", "-m", "pip", "install", "--upgrade", "pip", "setuptools"], + ["/opt/python/cp37-cp37m/bin/python", "-m", "pip", "install", ".", "--verbose"], + ["/opt/python/cp37-cp37m/bin/python", "-m", "pip", "install", "boto3", "autopep8"], + ["/opt/python/cp37-cp37m/bin/python", "-m", "unittest", "discover", "--verbose"], ["echo", "------ Python 3.6 ------"], ["/opt/python/cp36-cp36m/bin/python", "-m", "pip", "install", "--upgrade", "pip", "setuptools"], ["/opt/python/cp36-cp36m/bin/python", "-m", "pip", "install", ".", "--verbose"], @@ -32,22 +37,7 @@ ["/opt/python/cp35-cp35m/bin/python", "-m", "pip", "install", "--upgrade", "pip", "setuptools"], ["/opt/python/cp35-cp35m/bin/python", "-m", "pip", "install", ".", "--verbose"], ["/opt/python/cp35-cp35m/bin/python", "-m", "pip", "install", "boto3", "autopep8"], - ["/opt/python/cp35-cp35m/bin/python", "-m", "unittest", "discover", "--verbose"], - ["echo", "------ Python 3.4 ------"], - ["/opt/python/cp34-cp34m/bin/python", "-m", "pip", "install", "--upgrade", "pip", "setuptools"], - ["/opt/python/cp34-cp34m/bin/python", "-m", "pip", "install", ".", "--verbose"], - ["/opt/python/cp34-cp34m/bin/python", "-m", "pip", "install", "boto3", "autopep8"], - ["/opt/python/cp34-cp34m/bin/python", "-m", "unittest", "discover", "--verbose"], - ["echo", "------ Python 2.7 narrow-unicode ------"], - ["/opt/python/cp27-cp27m/bin/python", "-m", "pip", "install", "--upgrade", "pip", "setuptools"], - ["/opt/python/cp27-cp27m/bin/python", "-m", "pip", "install", ".", "--verbose"], - ["/opt/python/cp27-cp27m/bin/python", "-m", "pip", "install", "boto3", "autopep8"], - ["/opt/python/cp27-cp27m/bin/python", "-m", "unittest", "discover", "--verbose"], - ["echo", "------ Python 2.7 wide-unicode ------"], - ["/opt/python/cp27-cp27mu/bin/python", "-m", "pip", "install", "--upgrade", "pip", "setuptools"], - ["/opt/python/cp27-cp27mu/bin/python", "-m", "pip", "install", ".", "--verbose"], - ["/opt/python/cp27-cp27mu/bin/python", "-m", "pip", "install", "boto3", "autopep8"], - ["/opt/python/cp27-cp27mu/bin/python", "-m", "unittest", "discover", "--verbose"] + ["/opt/python/cp35-cp35m/bin/python", "-m", "unittest", "discover", "--verbose"] ], "run_tests": false, "_comment": "manylinux has all its own build steps, turn off 'tests' which is where normal build steps are declared. using data to program sucks" diff --git a/docsrc/conf.py b/docsrc/conf.py index 50f89adf..6a488226 100644 --- a/docsrc/conf.py +++ b/docsrc/conf.py @@ -19,7 +19,7 @@ # -- Project information ----------------------------------------------------- -project = 'AWS IoT Device SDK Python v2' +project = 'AWS IoT Device SDK v2 for Python' copyright = '%s, Amazon Web Services, Inc' % datetime.now().year author = 'Amazon Web Services, Inc' diff --git a/docsrc/index.rst b/docsrc/index.rst index 4f4869b2..e934f3df 100644 --- a/docsrc/index.rst +++ b/docsrc/index.rst @@ -1,10 +1,10 @@ -.. AWS IoT Device SDK Python v2 documentation master file, created by +.. AWS IoT Device SDK v2 for Python documentation master file, created by sphinx-quickstart on Mon Aug 17 14:57:36 2020. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -AWS IoT Device SDK Python v2 -============================ +AWS IoT Device SDK v2 for Python +================================ Python bindings for the AWS IoT Device API. @@ -18,7 +18,7 @@ API Reference ------------- .. toctree:: :maxdepth: 2 - + awsiot/greengrass_discovery awsiot/iotidentity awsiot/iotjobs diff --git a/samples/README.md b/samples/README.md index efdd4081..4c47248c 100644 --- a/samples/README.md +++ b/samples/README.md @@ -1,4 +1,4 @@ -# Sample apps for the AWS IoT Device SDK for Python v2 +# Sample apps for the AWS IoT Device SDK v2 for Python * [pubsub](#pubsub) * [shadow](#shadow) @@ -19,7 +19,7 @@ Source: `samples/pubsub.py` Run the sample like this: ``` -python pubsub.py --endpoint --root-ca --cert --key +python3 pubsub.py --endpoint --root-ca --cert --key ``` Your Thing's @@ -90,7 +90,7 @@ Source: `samples/shadow.py` Run the sample like this: ``` -python shadow.py --endpoint --root-ca --cert --key --thing-name +python3 shadow.py --endpoint --root-ca --cert --key --thing-name ``` Your Thing's @@ -176,7 +176,7 @@ Source: `samples/jobs.py` Run the sample like this: ``` -python jobs.py --endpoint --root-ca --cert --key --thing-name +python3 jobs.py --endpoint --root-ca --cert --key --thing-name ``` Your Thing's @@ -248,12 +248,12 @@ Source: `samples/fleetprovisioning.py` Run the sample using createKeysAndCertificate: ``` -python fleetprovisioning.py --endpoint --root-ca --cert --key --templateName --templateParameters +python3 fleetprovisioning.py --endpoint --root-ca --cert --key --templateName --templateParameters ``` Run the sample using createCertificateFromCsr: ``` -python fleetprovisioning.py --endpoint --root-ca --cert --key --templateName --templateParameters --csr +python3 fleetprovisioning.py --endpoint --root-ca --cert --key --templateName --templateParameters --csr ``` Your Thing's @@ -353,7 +353,7 @@ you'll need to substitute the name of the template you previously created, and o (Optional) Create a temporary provisioning claim certificate set:
-aws iot create-provisioning-claim --template-name [TemplateName] | python ../utils/parse_cert_set_result.py --path /tmp --filename provision
+aws iot create-provisioning-claim --template-name [TemplateName] | python3 ../utils/parse_cert_set_result.py --path /tmp --filename provision
 
The provisioning claim's cert and key set have been written to `/tmp/provision*`. Now you can use these temporary keys @@ -361,7 +361,7 @@ to perform the actual provisioning. If you are not using the temporary provisio and `--key` appropriately:
-python fleetprovisioning.py --endpoint [your endpoint]-ats.iot.[region].amazonaws.com --root-ca [pathToRootCA] --cert /tmp/provision.cert.pem --key /tmp/provision.private.key --templateName [TemplateName]--templateParameters "{\"SerialNumber\":\"1\",\"DeviceLocation\":\"Seattle\"}"
+python3 fleetprovisioning.py --endpoint [your endpoint]-ats.iot.[region].amazonaws.com --root-ca [pathToRootCA] --cert /tmp/provision.cert.pem --key /tmp/provision.private.key --templateName [TemplateName]--templateParameters "{\"SerialNumber\":\"1\",\"DeviceLocation\":\"Seattle\"}"
 
Notice that we provided substitution values for the two parameters in the template body, `DeviceLocation` and `SerialNumber`. @@ -383,13 +383,13 @@ openssl req -new -key /tmp/deviceCert.key -out /tmp/deviceCert.csr be skipped if you're using a certificate set capable of provisioning the device:
-aws iot create-provisioning-claim --template-name [TemplateName] | python ../utils/parse_cert_set_result.py --path /tmp --filename provision
+aws iot create-provisioning-claim --template-name [TemplateName] | python3 ../utils/parse_cert_set_result.py --path /tmp --filename provision
 
Finally, supply the certificate signing request while invoking the provisioning sample. As with the previous workflow, if using a permanent certificate set, replace the paths specified in the `--cert` and `--key` arguments:
-python fleetprovisioning.py --endpoint [your endpoint]-ats.iot.[region].amazonaws.com --root-ca [pathToRootCA] --cert /tmp/provision.cert.pem --key /tmp/provision.private.key --templateName [TemplateName]--templateParameters "{\"SerialNumber\":\"1\",\"DeviceLocation\":\"Seattle\"}" --csr /tmp/deviceCert.csr
+python3 fleetprovisioning.py --endpoint [your endpoint]-ats.iot.[region].amazonaws.com --root-ca [pathToRootCA] --cert /tmp/provision.cert.pem --key /tmp/provision.private.key --templateName [TemplateName]--templateParameters "{\"SerialNumber\":\"1\",\"DeviceLocation\":\"Seattle\"}" --csr /tmp/deviceCert.csr
 
## basic discovery diff --git a/samples/fleetprovisioning.py b/samples/fleetprovisioning.py index f641a8eb..781162b9 100644 --- a/samples/fleetprovisioning.py +++ b/samples/fleetprovisioning.py @@ -1,8 +1,6 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0. -from __future__ import absolute_import -from __future__ import print_function import argparse from awscrt import auth, http, io, mqtt from awsiot import iotidentity @@ -63,7 +61,7 @@ createCertificateFromCsrResponse = None registerThingResponse = None -class LockedData(object): +class LockedData: def __init__(self): self.lock = threading.Lock() self.disconnect_called = False diff --git a/samples/jobs.py b/samples/jobs.py index 85430257..f662c64b 100644 --- a/samples/jobs.py +++ b/samples/jobs.py @@ -1,8 +1,6 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0. -from __future__ import absolute_import -from __future__ import print_function import argparse from awscrt import auth, http, io, mqtt from awsiot import iotjobs @@ -64,7 +62,7 @@ jobs_client = None thing_name = "" -class LockedData(object): +class LockedData: def __init__(self): self.lock = threading.Lock() self.disconnect_called = False diff --git a/samples/pubsub.py b/samples/pubsub.py index d1b3396d..d423a5e5 100644 --- a/samples/pubsub.py +++ b/samples/pubsub.py @@ -1,8 +1,6 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0. -from __future__ import absolute_import -from __future__ import print_function import argparse from awscrt import io, mqtt, auth, http from awsiot import mqtt_connection_builder diff --git a/samples/shadow.py b/samples/shadow.py index 3ff87892..780e13b4 100644 --- a/samples/shadow.py +++ b/samples/shadow.py @@ -1,8 +1,6 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0. -from __future__ import absolute_import -from __future__ import print_function import argparse from awscrt import auth, io, mqtt, http from awsiot import iotshadow @@ -64,7 +62,7 @@ SHADOW_VALUE_DEFAULT = "off" -class LockedData(object): +class LockedData: def __init__(self): self.lock = threading.Lock() self.shadow_value = None @@ -207,10 +205,7 @@ def user_input_thread_fn(): while True: try: # Read user input - try: - new_value = raw_input() # python 2 only - except NameError: - new_value = input() # python 3 only + new_value = input() # If user wants to quit sample, then quit. # Otherwise change the shadow value. diff --git a/setup.py b/setup.py index 92e5e391..20dca581 100644 --- a/setup.py +++ b/setup.py @@ -11,11 +11,9 @@ description='AWS IoT SDK based on the AWS Common Runtime', author='AWS SDK Common Runtime Team', url='https://github.com/aws/aws-iot-device-sdk-python-v2', - packages = ['awsiot'], + packages=['awsiot'], install_requires=[ - 'awscrt==0.8.0', - 'futures;python_version<"3.2"', - 'typing;python_version<"3.5"', + 'awscrt==0.9.0', ], - python_requires='>=2.7', + python_requires='>=3.5', ) diff --git a/test/test_samples.py b/test/test_samples.py index 35073856..eac74442 100644 --- a/test/test_samples.py +++ b/test/test_samples.py @@ -1,6 +1,5 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0. -from __future__ import absolute_import, print_function import awsiot import boto3 import botocore.exceptions @@ -43,10 +42,7 @@ def get(): # boto3 caches the HTTPS connection for the API calls, which appears to the unit test # framework as a leak, so ignore it, that's not what we're testing here - try: - warnings.simplefilter('ignore', ResourceWarning) - except NameError: # Python 2 has no ResourceWarning - pass + warnings.simplefilter('ignore', ResourceWarning) try: secrets = boto3.client('secretsmanager') diff --git a/utils/parse_cert_set_result.py b/utils/parse_cert_set_result.py index d07fd660..047156fb 100644 --- a/utils/parse_cert_set_result.py +++ b/utils/parse_cert_set_result.py @@ -10,7 +10,7 @@ Example usage: -aws iot create-provisioning-claim --template-name | python parse_cert_set_result.py --path --filename +aws iot create-provisioning-claim --template-name | python3 parse_cert_set_result.py --path --filename """