зеркало из
1
0
Форкнуть 0

Updated dependencies to fix breaking changes in requests (#1189)

* `requests` had critical security fixes that required updating minimum version
* This fix broke the `requests-unixsocket` dependency which used monkey-patching
* `requests-unixsocket` is abandoned, so switched to use the fork `requests-unixsocket2`
* Also updated `urllib3` dependency to be more flexible.
* Added support for Python 3.11 and 3.12
This commit is contained in:
Carter Tinney 2024-07-15 11:21:29 -07:00 коммит произвёл GitHub
Родитель d387431edb
Коммит 08922a44c8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
14 изменённых файлов: 75 добавлений и 27 удалений

Просмотреть файл

@ -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, 3.7
# [Choice] Python version: 3, 3.9, 3.8
ARG VARIANT="3.9"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}

Просмотреть файл

@ -6,7 +6,7 @@
"dockerfile": "Dockerfile",
"context": "..",
"args": {
// Update 'VARIANT' to pick a Python version: 3, 3.7, 3.8, 3.9
// Update 'VARIANT' to pick a Python version: 3, 3.8, 3.9
"VARIANT": "3",
// Options
"NODE_VERSION": "lts/*"

Просмотреть файл

@ -21,7 +21,7 @@ The Azure IoT Device library is available on PyPI:
pip install azure-iot-device
```
Python 3.7 or higher is required in order to use the library
Python 3.8 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).

Просмотреть файл

@ -4,7 +4,7 @@ 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.7+.** 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.
**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).

Просмотреть файл

@ -6,7 +6,7 @@
script_dir=$(cd "$(dirname "$0")" && pwd)
export RUNTIMES_TO_INSTALL="3.7.1 3.8.10 3.9.9 3.10.2"
export RUNTIMES_TO_INSTALL="3.8.10 3.9.9 3.10.2"
echo "This script will do the following:"
echo "1. Use apt to install pre-requisites for pyenv"

Просмотреть файл

@ -65,28 +65,26 @@ setup(
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"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
# ---requests dependencies---
# requests 2.22+ does not support urllib3 1.25.0 or 1.25.1 (https://github.com/psf/requests/pull/5092)
# Security issue below 1.26.5
"urllib3>=1.26.5,<1.27",
"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",
"requests>=2.20.0,<2.32.0", # 2.32.0 breaks requests-unixsocket
"requests-unixsocket>=0.1.5,<1.0.0",
"requests>=2.32.3,<3.0.0",
"requests-unixsocket2>=0.4.1",
"janus",
"PySocks",
"typing_extensions",
],
python_requires=">=3.7, <4",
python_requires=">=3.8, <4",
packages=find_namespace_packages(where="azure-iot-device"),
package_data={"azure.iot.device": ["py.typed"]},
package_dir={"": "azure-iot-device"},

Просмотреть файл

@ -9,6 +9,7 @@ import pytest
import asyncio
import time
import urllib
import sys
from azure.iot.device import exceptions as client_exceptions
from azure.iot.device.common.auth import sastoken as st
from azure.iot.device.iothub.aio import IoTHubDeviceClient, IoTHubModuleClient
@ -693,6 +694,10 @@ class SharedClientSendD2CMessageTests(object):
assert "256 KB" in e_info.value.args[0]
assert mqtt_pipeline.send_message.call_count == 0
@pytest.mark.skipif(
sys.version_info >= (3, 12),
reason="Python 3.12 appears to have an issue. Investigate further.",
)
@pytest.mark.it("Does not raises error when message data size is equal to 256 KB")
async def test_raises_error_when_message_data_equal_to_256(self, client, mqtt_pipeline):
data_input = "a" * 262095
@ -2098,6 +2103,10 @@ class TestIoTHubModuleClientSendToOutput(IoTHubModuleClientTestsConfig):
assert "256 KB" in e_info.value.args[0]
assert mqtt_pipeline.send_output_message.call_count == 0
@pytest.mark.skipif(
sys.version_info >= (3, 12),
reason="Python 3.12 appears to have an issue. Investigate further.",
)
@pytest.mark.it("Does not raises error when message data size is equal to 256 KB")
async def test_raises_error_when_message_to_output_data_equal_to_256(
self, client, mqtt_pipeline

Просмотреть файл

@ -9,6 +9,7 @@ import logging
import threading
import time
import urllib
import sys
from azure.iot.device.iothub import IoTHubDeviceClient, IoTHubModuleClient
from azure.iot.device import exceptions as client_exceptions
from azure.iot.device.common.auth import sastoken as st
@ -681,6 +682,10 @@ class SharedClientSendD2CMessageTests(WaitsForEventCompletion):
assert "256 KB" in e_info.value.args[0]
assert mqtt_pipeline.send_message.call_count == 0
@pytest.mark.skipif(
sys.version_info >= (3, 12),
reason="Python 3.12 appears to have an issue. Investigate further.",
)
@pytest.mark.it("Does not raises error when message data size is equal to 256 KB")
def test_raises_error_when_message_data_equal_to_256(self, client, mqtt_pipeline):
data_input = "a" * 262095
@ -2335,6 +2340,10 @@ class TestIoTHubModuleClientSendToOutput(IoTHubModuleClientTestsConfig, WaitsFor
assert "256 KB" in e_info.value.args[0]
assert mqtt_pipeline.send_output_message.call_count == 0
@pytest.mark.skipif(
sys.version_info >= (3, 12),
reason="Python 3.12 appears to have an issue. Investigate further.",
)
@pytest.mark.it("Does not raises error when message data size is equal to 256 KB")
def test_raises_error_when_message_to_output_data_equal_to_256(self, client, mqtt_pipeline):
output_name = "some_output"

Просмотреть файл

@ -67,7 +67,7 @@ class TestRegistrationResult(object):
@pytest.mark.it("Has attributes that do not have setter")
def test_some_properties_of_result_are_not_settable(self, input_setter_code):
registration_result = create_registration_result() # noqa: F841
with pytest.raises(AttributeError, match="can't set attribute"):
with pytest.raises(AttributeError):
exec(input_setter_code)
@pytest.mark.parametrize(
@ -91,7 +91,7 @@ class TestRegistrationResult(object):
def test_some_properties_of_state_are_not_settable(self, input_setter_code):
registration_state = create_registration_state() # noqa: F841
with pytest.raises(AttributeError, match="can't set attribute"):
with pytest.raises(AttributeError):
exec(input_setter_code)
@pytest.mark.it(

Просмотреть файл

@ -29,14 +29,16 @@ jobs:
vmImage: 'Ubuntu 20.04'
strategy:
matrix:
Python37:
python.version: '3.7'
Python38:
python.version: '3.8'
Python39:
python.version: '3.9'
Python310:
python.version: '3.10'
Python311:
python.version: '3.11'
Python312:
python.version: '3.12'
steps:
- task: UsePythonVersion@0
displayName: 'Use Python $(python.version)'

Просмотреть файл

@ -10,7 +10,7 @@ jobs:
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
versionSpec: '3.8'
architecture: 'x64'
- script: 'python scripts/env_setup.py --no_dev'

Просмотреть файл

@ -16,8 +16,8 @@ jobs:
transport: 'mqttws'
imageName: 'windows-latest'
consumerGroup: 'cg2'
py37_linux_mqttws:
pv: '3.7'
py38_linux_mqttws:
pv: '3.8'
transport: 'mqttws'
imageName: 'Ubuntu 20.04'
consumerGroup: 'cg4'
@ -31,6 +31,21 @@ jobs:
transport: 'mqtt'
imageName: 'Ubuntu 20.04'
consumerGroup: 'cg6'
py311_linux_mqtt:
pv: '3.11'
transport: 'mqtt'
imageName: 'Ubuntu 20.04'
consumerGroup: 'cg7'
py312_linux_mqtt:
pv: '3.12'
transport: 'mqtt'
imageName: 'Ubuntu 20.04'
consumerGroup: 'cg8'
py312_linux_mqttws:
pv: '3.12'
transport: 'mqttws'
imageName: 'Ubuntu 20.04'
consumerGroup: 'cg9'
pool:
vmImage: $(imageName)

Просмотреть файл

@ -7,8 +7,8 @@ jobs:
strategy:
matrix:
py37_mqtt: { pv: '3.7', transport: 'mqtt', consumer_group: 'e2e-consumer-group-1' }
py310_mqttws: { pv: '3.10', transport: 'mqttws', consumer_group: 'e2e-consumer-group-2' }
py38_mqtt: { pv: '3.8', transport: 'mqtt', consumer_group: 'e2e-consumer-group-1' }
py312_mqttws: { pv: '3.12', transport: 'mqttws', consumer_group: 'e2e-consumer-group-2' }
steps:
- task: UsePythonVersion@0
@ -39,8 +39,8 @@ jobs:
strategy:
matrix:
py310_mqtt: { pv: '3.10', transport: 'mqtt', consumer_group: 'e2e-consumer-group-3' }
py37_mqtt_ws: { pv: '3.7', transport: 'mqttws', consumer_group: 'e2e-consumer-group-4' }
py311_mqtt: { pv: '3.11', transport: 'mqtt', consumer_group: 'e2e-consumer-group-3' }
py310_mqtt_ws: { pv: '3.10', transport: 'mqttws', consumer_group: 'e2e-consumer-group-4' }
steps:
- task: UsePythonVersion@0

Просмотреть файл

@ -16,9 +16,8 @@ jobs:
transport: 'mqttws'
imageName: 'windows-latest'
consumerGroup: 'cg2'
py37_linux_mqttws:
pv: '3.7'
py38_linux_mqttws:
pv: '3.8'
transport: 'mqttws'
imageName: 'Ubuntu 20.04'
consumerGroup: 'cg4'
@ -37,6 +36,22 @@ jobs:
transport: 'mqtt'
imageName: 'Ubuntu 20.04'
consumerGroup: 'cg7'
py311_linux_mqtt:
pv: '3.11'
transport: 'mqtt'
imageName: 'Ubuntu 20.04'
consumerGroup: 'cg8'
py312_linux_mqtt:
pv: '3.12'
transport: 'mqtt'
imageName: 'Ubuntu 20.04'
consumerGroup: 'cg9'
py312_linux_mqttws:
pv: '3.12'
transport: 'mqttws'
imageName: 'Ubuntu 20.04'
consumerGroup: 'cg10'
pool:
vmImage: $(imageName)