From 2736173fa10999c9f01de49969b8c778815f8b5c Mon Sep 17 00:00:00 2001 From: Carter Tinney Date: Fri, 16 Jan 2026 09:47:50 -0800 Subject: [PATCH 1/2] updates --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 2 +- README.md | 2 +- .../azure/iot/device/common/mqtt_transport.py | 6 +++++- samples/README.md | 2 -- scripts/configure-virtual-environments.sh | 2 +- setup.py | 15 +++++++-------- tests/unit/common/test_mqtt_transport.py | 6 +++++- vsts/dps-e2e.yaml | 2 +- vsts/python-canary.yaml | 8 ++++---- vsts/python-e2e.yaml | 2 +- 11 files changed, 27 insertions(+), 22 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 4b9e3ee14..d3089fb1a 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,6 +1,6 @@ # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.192.0/containers/python-3/.devcontainer/base.Dockerfile -# [Choice] Python version: 3, 3.9, 3.8 +# [Choice] Python version: 3, 3.9, ARG VARIANT="3.9" FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ffe15824b..ba9200b89 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -6,7 +6,7 @@ "dockerfile": "Dockerfile", "context": "..", "args": { - // Update 'VARIANT' to pick a Python version: 3, 3.8, 3.9 + // Update 'VARIANT' to pick a Python version: 3, 3.9 "VARIANT": "3", // Options "NODE_VERSION": "lts/*" diff --git a/README.md b/README.md index edf782e96..a50ed4a27 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ The Azure IoT Device library is available on PyPI: pip install azure-iot-device ``` -Python 3.8 or higher is required in order to use the library +Python 3.9 or higher is required in order to use the library ## Using the library API documentation for this package is available via [**Microsoft Docs**](https://docs.microsoft.com/python/api/azure-iot-device/azure.iot.device?view=azure-python). diff --git a/azure-iot-device/azure/iot/device/common/mqtt_transport.py b/azure-iot-device/azure/iot/device/common/mqtt_transport.py index cf54a0416..4afebfa38 100644 --- a/azure-iot-device/azure/iot/device/common/mqtt_transport.py +++ b/azure-iot-device/azure/iot/device/common/mqtt_transport.py @@ -140,6 +140,7 @@ def _create_mqtt_client(self): if self._websockets: logger.info("Creating client for connecting using MQTT over websockets") mqtt_client = mqtt.Client( + callback_api_version=mqtt.CallbackAPIVersion.VERSION1, client_id=self._client_id, clean_session=False, protocol=mqtt.MQTTv311, @@ -149,7 +150,10 @@ def _create_mqtt_client(self): else: logger.info("Creating client for connecting using MQTT over TCP") mqtt_client = mqtt.Client( - client_id=self._client_id, clean_session=False, protocol=mqtt.MQTTv311 + callback_api_version=mqtt.CallbackAPIVersion.VERSION1, + client_id=self._client_id, + clean_session=False, + protocol=mqtt.MQTTv311, ) if self._proxy_options: diff --git a/samples/README.md b/samples/README.md index 6697e79ff..0fbc1be86 100644 --- a/samples/README.md +++ b/samples/README.md @@ -4,8 +4,6 @@ This directory contains samples showing how to use the various features of the M ## Quick Start - Simple Telemetry Sample (send message) -**Note that this sample is configured for Python 3.8+.** To ensure that your Python version is up to date, run `python --version`. If you have both Python 2 and Python 3 installed (and are using a Python 3 environment for this SDK), then install all libraries using `pip3` as opposed to `pip`. This ensures that the libraries are installed to your Python 3 runtime. - 1. Install the [Azure CLI](https://docs.microsoft.com/cli/azure/install-azure-cli?view=azure-cli-latest) (or use the [Azure Cloud Shell](https://shell.azure.com/)) and use it to [create an Azure IoT Hub](https://docs.microsoft.com/cli/azure/iot/hub?view=azure-cli-latest#az_iot_hub_create). ```bash diff --git a/scripts/configure-virtual-environments.sh b/scripts/configure-virtual-environments.sh index 5bf600455..4f5eddd73 100755 --- a/scripts/configure-virtual-environments.sh +++ b/scripts/configure-virtual-environments.sh @@ -6,7 +6,7 @@ script_dir=$(cd "$(dirname "$0")" && pwd) -export RUNTIMES_TO_INSTALL="3.8.10 3.9.9 3.10.2" +export RUNTIMES_TO_INSTALL="3.9.9 3.10.2" echo "This script will do the following:" echo "1. Use apt to install pre-requisites for pyenv" diff --git a/setup.py b/setup.py index ca3f7df52..c4ade0823 100644 --- a/setup.py +++ b/setup.py @@ -65,26 +65,25 @@ "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", ], install_requires=[ - # Define sub-dependencies due to pip dependency resolution bug - # https://github.com/pypa/pip/issues/988 - "urllib3>=2.2.2,<3.0.0", - # Actual project dependencies + # # Define sub-dependencies due to pip dependency resolution bug + # # https://github.com/pypa/pip/issues/988 + # "urllib3>=2.2.2,<3.0.0", + # # Actual project dependencies "deprecation>=2.1.0,<3.0.0", - "paho-mqtt>=1.6.1,<2.0.0", + "paho-mqtt>=2.0.0,<3.0.0", "requests>=2.32.3,<3.0.0", - "requests-unixsocket2>=0.4.1", + "requests-unixsocket>=0.4.1,<1.0.0", "janus", "PySocks", "typing_extensions", ], - python_requires=">=3.8, <4", + python_requires=">=3.9, <4", packages=find_namespace_packages(where="azure-iot-device"), package_data={"azure.iot.device": ["py.typed"]}, package_dir={"": "azure-iot-device"}, diff --git a/tests/unit/common/test_mqtt_transport.py b/tests/unit/common/test_mqtt_transport.py index ee547d03a..74967a8ab 100644 --- a/tests/unit/common/test_mqtt_transport.py +++ b/tests/unit/common/test_mqtt_transport.py @@ -202,7 +202,10 @@ def test_instantiates_mqtt_client(self, mocker): assert mock_mqtt_client_constructor.call_count == 1 assert mock_mqtt_client_constructor.call_args == mocker.call( - client_id=fake_device_id, clean_session=False, protocol=mqtt.MQTTv311 + callback_api_version=mqtt.CallbackAPIVersion.VERSION1, + client_id=fake_device_id, + clean_session=False, + protocol=mqtt.MQTTv311, ) @pytest.mark.it( @@ -221,6 +224,7 @@ def test_configures_mqtt_websockets(self, mocker): assert mock_mqtt_client_constructor.call_count == 1 assert mock_mqtt_client_constructor.call_args == mocker.call( + callback_api_version=mqtt.CallbackAPIVersion.VERSION1, client_id=fake_device_id, clean_session=False, protocol=mqtt.MQTTv311, diff --git a/vsts/dps-e2e.yaml b/vsts/dps-e2e.yaml index d91d202af..02badeb8d 100644 --- a/vsts/dps-e2e.yaml +++ b/vsts/dps-e2e.yaml @@ -270,7 +270,7 @@ stages: steps: - task: UsePythonVersion@0 inputs: - versionSpec: '3.8' + versionSpec: '3.9' architecture: 'x64' - script: 'python scripts/env_setup.py --no_dev' diff --git a/vsts/python-canary.yaml b/vsts/python-canary.yaml index 667674b78..8a88b751f 100644 --- a/vsts/python-canary.yaml +++ b/vsts/python-canary.yaml @@ -16,13 +16,13 @@ jobs: transport: 'mqttws' imageName: 'windows-latest' consumerGroup: 'cg2' - py38_linux_mqttws: - pv: '3.8' + py39_linux_mqttws: + pv: '3.9' transport: 'mqttws' imageName: 'Ubuntu 20.04' consumerGroup: 'cg4' - py38_linux_mqtt: - pv: '3.8' + py39_linux_mqtt: + pv: '3.9' transport: 'mqtt' imageName: 'Ubuntu 20.04' consumerGroup: 'cg5' diff --git a/vsts/python-e2e.yaml b/vsts/python-e2e.yaml index 8eb80418a..fc8c9569b 100644 --- a/vsts/python-e2e.yaml +++ b/vsts/python-e2e.yaml @@ -56,7 +56,7 @@ stages: strategy: matrix: - py38_mqtt: { pv: '3.8', transport: 'mqtt', consumer_group: 'cg1' } + py39_mqtt: { pv: '3.9', transport: 'mqtt', consumer_group: 'cg1' } py312_mqttws: { pv: '3.12', transport: 'mqttws', consumer_group: 'cg2' } steps: From f16b3edcbfbaff7f61784b27d0e45b0425ae7106 Mon Sep 17 00:00:00 2001 From: Carter Tinney Date: Fri, 16 Jan 2026 09:49:50 -0800 Subject: [PATCH 2/2] removed subdeps --- setup.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/setup.py b/setup.py index c4ade0823..ad0010534 100644 --- a/setup.py +++ b/setup.py @@ -71,10 +71,6 @@ "Programming Language :: Python :: 3.12", ], install_requires=[ - # # Define sub-dependencies due to pip dependency resolution bug - # # https://github.com/pypa/pip/issues/988 - # "urllib3>=2.2.2,<3.0.0", - # # Actual project dependencies "deprecation>=2.1.0,<3.0.0", "paho-mqtt>=2.0.0,<3.0.0", "requests>=2.32.3,<3.0.0",