-
Notifications
You must be signed in to change notification settings - Fork 20
fix(deps): make uamqp optional on ARM macOS to fix installation failure #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
marcodalessandro
wants to merge
11
commits into
Azure:main
Choose a base branch
from
marcodalessandro:fix/uamqp-macos-compatibility
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ac550ac
fix(deps): make uamqp optional on ARM macOS to fix installation failure
marcodalessandro d038f75
fix: address PR review feedback
marcodalessandro a9353fb
ci: add GitHub Actions workflow to run tests on PRs
marcodalessandro 98ca383
fix: replace six.moves.urllib with stdlib urllib.parse
marcodalessandro ff40928
fix(tests): import TransportType from registry manager instead of uamqp
marcodalessandro 34b5ff5
fix(tests): skip uamqp-dependent tests when uamqp not installed
marcodalessandro f2e5db3
fix: address second round of PR review feedback
marcodalessandro e692e44
fix: revert urllib.parse, add six as explicit dependency
marcodalessandro 0ce44e7
fix: update TransportType docstring references
marcodalessandro 28424d6
fix(tests): restore builtins.__import__ before module reload
marcodalessandro be66d62
fix: rename extras_require from [amqp] to [uamqp] for clarity
marcodalessandro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| name: Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [ubuntu-latest, windows-latest, macos-latest] | ||
| python-version: ["3.9", "3.10"] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -e . | ||
| pip install pytest pytest-mock pytest-testdox pytest-timeout | ||
|
|
||
| - name: Run tests | ||
| run: python -m pytest tests/ -v |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # Azure IoTHub Service SDK | ||
| # Azure IoTHub Service SDK | ||
|
|
||
| The Azure IoTHub Service SDK for Python provides functionality for communicating with the Azure IoT Hub. | ||
|
|
||
|
|
@@ -8,21 +8,90 @@ The SDK provides the following clients: | |
|
|
||
| * ### IoT Hub Registry Manager | ||
|
|
||
| * Provides CRUD operations for device on IoTHub | ||
| * Get statistics about the IoTHub service and devices | ||
| * CRUD operations for devices and modules on IoT Hub | ||
| * Get service and device registry statistics | ||
| * Query device twins using a SQL-like language | ||
| * Retrieve and update device twins and module twins | ||
| * Invoke direct methods on devices and modules | ||
| * **Cloud-to-Device (C2D) messaging** over AMQP (requires `uamqp` — see [Installation](#installation) below) | ||
| * Bulk create, update, or delete device identities | ||
|
|
||
| * ### IoT Hub Configuration Manager | ||
|
|
||
| * CRUD operations for IoT Hub configurations | ||
|
|
||
| * ### IoT Hub Job Manager | ||
|
|
||
| * Schedule and manage jobs for twin updates and direct method invocations | ||
| * Import and export device identities in bulk | ||
|
|
||
| * ### IoT Hub HTTP Runtime Manager | ||
|
|
||
| * Receive and complete/reject/abandon Cloud-to-Device messages from the device feedback queue | ||
|
|
||
| * ### Digital Twin Client | ||
|
|
||
| * Get and update digital twins | ||
| * Invoke commands on digital twin components | ||
|
|
||
| ## Installation | ||
|
|
||
| ```python | ||
| ### Standard installation | ||
|
|
||
| ```bash | ||
| pip install azure-iot-hub | ||
| ``` | ||
|
|
||
| This installs all dependencies needed for every feature **except** Cloud-to-Device (C2D) AMQP messaging on ARM macOS / Apple Silicon (see below). | ||
|
|
||
| ### Cloud-to-Device (C2D) messaging and `uamqp` | ||
|
|
||
| The `send_c2d_message` method on `IoTHubRegistryManager` uses the [uamqp](https://pypi.org/project/uamqp/) library, which is a C extension that must be compiled from source. | ||
|
|
||
| | Platform | C2D messaging support | Notes | | ||
| |---|---|---| | ||
| | Windows | Included automatically | `uamqp` is installed as part of `pip install azure-iot-hub` | | ||
| | Linux | Included automatically | `uamqp` is installed as part of `pip install azure-iot-hub` | | ||
| | macOS (Intel) | Included automatically | `uamqp` is installed as part of `pip install azure-iot-hub` | | ||
| | macOS (Apple Silicon / ARM) | **Not installed automatically** | Recent versions of Xcode/clang enforce stricter C type checking that breaks the `uamqp` build. See below. | | ||
|
|
||
|
Comment on lines
+51
to
+57
|
||
| #### Apple Silicon macOS: opting in to C2D messaging | ||
|
|
||
| If your Xcode and clang version are compatible, you can install `uamqp` explicitly using the `uamqp` extra: | ||
|
|
||
| ```bash | ||
| pip install azure-iot-hub[uamqp] | ||
| ``` | ||
|
|
||
| If `uamqp` cannot be built in your environment, all other SDK features (device/module CRUD, twin operations, direct methods, digital twins, jobs, etc.) work without it. Calling `send_c2d_message` without `uamqp` installed raises an `ImportError` with instructions. | ||
|
|
||
| #### AMQP transport options | ||
|
|
||
| When `uamqp` is available, C2D messaging supports two transport modes, controlled by the `transport_type` parameter: | ||
|
|
||
| ```python | ||
| from uamqp import TransportType | ||
|
|
||
| # Default: AMQP over TCP (port 5671) | ||
| registry_manager = IoTHubRegistryManager.from_connection_string(connection_string) | ||
|
|
||
| # AMQP over WebSocket (port 443) — useful when port 5671 is blocked by a firewall | ||
| registry_manager = IoTHubRegistryManager.from_connection_string( | ||
| connection_string, | ||
| transport_type=TransportType.AmqpOverWebsocket | ||
| ) | ||
| ``` | ||
|
|
||
| ## IoTHub Samples | ||
|
|
||
| Check out the [samples repository](https://github.com/Azure/azure-iot-hub-python/tree/main/samples) for more detailed samples | ||
| Check out the [samples repository](https://github.com/Azure/azure-iot-hub-python/tree/main/samples) for more detailed samples. | ||
|
|
||
| ## Getting help and finding API docs | ||
| Notable C2D samples: | ||
|
|
||
| - [`iothub_registry_manager_c2d_sample.py`](https://github.com/Azure/azure-iot-hub-python/tree/main/samples/iothub_registry_manager_c2d_sample.py) — basic C2D messaging | ||
| - [`iothub_registry_manager_c2d_amqp_over_websocket_sample.py`](https://github.com/Azure/azure-iot-hub-python/tree/main/samples/iothub_registry_manager_c2d_amqp_over_websocket_sample.py) — C2D over WebSocket | ||
|
|
||
| ## Getting help and finding API docs | ||
|
|
||
| API documentation for this package is available via [Microsoft Docs](https://docs.microsoft.com/python/api/azure-iot-hub/azure.iot.hub?view=azure-python) | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,4 +6,4 @@ | |
| """This module defines constants for use across the azure-iot-hub package | ||
| """ | ||
|
|
||
| VERSION = "2.7.0" | ||
| VERSION = "2.8.0" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.