Skip to content

Commit d89f6e7

Browse files
fix build for python-uamqp (#15066)
1 parent fc02962 commit d89f6e7

3 files changed

Lines changed: 193 additions & 7 deletions

File tree

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
From 6a074bff2c2a1d531f7d379095c924d81abd2cdf Mon Sep 17 00:00:00 2001
2+
From: akhila-guruju <v-guakhila@microsoft.com>
3+
Date: Wed, 12 Nov 2025 07:22:20 +0000
4+
Subject: [PATCH] fix cython-0.29 compatibility error
5+
6+
Patch Reference: https://cython.readthedocs.io/en/latest/src/userguide/migrating_to_cy30.html#exception-values-and-noexcept
7+
---
8+
src/amqp_management.pyx | 6 +++---
9+
src/connection.pyx | 6 +++---
10+
src/message_receiver.pyx | 2 +-
11+
src/message_sender.pyx | 4 ++--
12+
4 files changed, 9 insertions(+), 9 deletions(-)
13+
14+
diff --git a/src/amqp_management.pyx b/src/amqp_management.pyx
15+
index a055ccf..fbbdfb9 100644
16+
--- a/src/amqp_management.pyx
17+
+++ b/src/amqp_management.pyx
18+
@@ -95,19 +95,19 @@ cdef class cManagementOperation(StructBase):
19+
20+
#### Management Link Callbacks
21+
22+
-cdef void on_amqp_management_open_complete(void* context, c_amqp_management.AMQP_MANAGEMENT_OPEN_RESULT_TAG open_result):
23+
+cdef void on_amqp_management_open_complete(void* context, c_amqp_management.AMQP_MANAGEMENT_OPEN_RESULT_TAG open_result) noexcept:
24+
_logger.debug("Management link open: %r", open_result)
25+
if context != NULL:
26+
context_obj = <object>context
27+
context_obj._management_open_complete(open_result)
28+
29+
-cdef void on_amqp_management_error(void* context):
30+
+cdef void on_amqp_management_error(void* context) noexcept:
31+
_logger.debug("Management link error")
32+
if context != NULL:
33+
context_obj = <object>context
34+
context_obj._management_operation_error()
35+
36+
-cdef void on_execute_operation_complete(void* context, c_amqp_management.AMQP_MANAGEMENT_EXECUTE_OPERATION_RESULT_TAG execute_operation_result, unsigned int status_code, const char* status_description, c_message.MESSAGE_HANDLE message):
37+
+cdef void on_execute_operation_complete(void* context, c_amqp_management.AMQP_MANAGEMENT_EXECUTE_OPERATION_RESULT_TAG execute_operation_result, unsigned int status_code, const char* status_description, c_message.MESSAGE_HANDLE message) noexcept:
38+
cdef c_message.MESSAGE_HANDLE cloned
39+
description = "None" if <void*>status_description == NULL else status_description
40+
_logger.debug("Management op complete: %r, status code: %r, description: %r", execute_operation_result, status_code, description)
41+
diff --git a/src/connection.pyx b/src/connection.pyx
42+
index 2b13401..d36126a 100644
43+
--- a/src/connection.pyx
44+
+++ b/src/connection.pyx
45+
@@ -79,7 +79,7 @@ cdef class Connection(StructBase):
46+
self._c_value = value._c_value
47+
self._create()
48+
49+
- cdef create(self, XIO sasl_client, const char* hostname, const char* container_id, c_connection.ON_CONNECTION_STATE_CHANGED on_connection_state_changed, c_xio.ON_IO_ERROR on_io_error, void* callback_context):
50+
+ cdef create(self, XIO sasl_client, const char* hostname, const char* container_id, c_connection.ON_CONNECTION_STATE_CHANGED on_connection_state_changed, c_xio.ON_IO_ERROR on_io_error, void* callback_context) noexcept:
51+
self.destroy()
52+
self._sasl_client = sasl_client
53+
self._c_value = c_connection.connection_create2(sasl_client._c_value, hostname, container_id, NULL, NULL, on_connection_state_changed, callback_context, on_io_error, callback_context)
54+
@@ -183,7 +183,7 @@ cdef class Connection(StructBase):
55+
56+
#### Callback
57+
58+
-cdef void on_connection_state_changed(void* context, c_connection.CONNECTION_STATE_TAG new_connection_state, c_connection.CONNECTION_STATE_TAG previous_connection_state):
59+
+cdef void on_connection_state_changed(void* context, c_connection.CONNECTION_STATE_TAG new_connection_state, c_connection.CONNECTION_STATE_TAG previous_connection_state) noexcept:
60+
if <void*>context != NULL:
61+
context_pyobj = <PyObject*>context
62+
if context_pyobj.ob_refcnt == 0: # context is being garbage collected, skip the callback
63+
@@ -196,7 +196,7 @@ cdef void on_connection_state_changed(void* context, c_connection.CONNECTION_STA
64+
_logger.info("Unknown connection state changed: %r to %r", previous_connection_state, new_connection_state)
65+
66+
67+
-cdef void on_io_error(void* context):
68+
+cdef void on_io_error(void* context) noexcept:
69+
if <void*>context != NULL:
70+
context_obj = <object>context
71+
if hasattr(context_obj, '_io_error'):
72+
diff --git a/src/message_receiver.pyx b/src/message_receiver.pyx
73+
index b99647c..2cc020e 100644
74+
--- a/src/message_receiver.pyx
75+
+++ b/src/message_receiver.pyx
76+
@@ -120,7 +120,7 @@ cdef class cMessageReceiver(StructBase):
77+
78+
#### Callbacks (context is a MessageReceiver instance)
79+
80+
-cdef void on_message_receiver_state_changed(void* context, c_message_receiver.MESSAGE_RECEIVER_STATE_TAG new_state, c_message_receiver.MESSAGE_RECEIVER_STATE_TAG previous_state):
81+
+cdef void on_message_receiver_state_changed(void* context, c_message_receiver.MESSAGE_RECEIVER_STATE_TAG new_state, c_message_receiver.MESSAGE_RECEIVER_STATE_TAG previous_state) noexcept:
82+
if context != NULL:
83+
context_pyobj = <PyObject*>context
84+
if context_pyobj.ob_refcnt == 0: # context is being garbage collected, skip the callback
85+
diff --git a/src/message_sender.pyx b/src/message_sender.pyx
86+
index 738207a..2922ec9 100644
87+
--- a/src/message_sender.pyx
88+
+++ b/src/message_sender.pyx
89+
@@ -97,7 +97,7 @@ cdef class cMessageSender(StructBase):
90+
#### Callbacks (context is a MessageSender instance)
91+
92+
93+
-cdef void on_message_send_complete(void* context, c_message_sender.MESSAGE_SEND_RESULT_TAG send_result, c_amqpvalue.AMQP_VALUE delivery_state):
94+
+cdef void on_message_send_complete(void* context, c_message_sender.MESSAGE_SEND_RESULT_TAG send_result, c_amqpvalue.AMQP_VALUE delivery_state) noexcept:
95+
cdef c_amqpvalue.AMQP_VALUE send_data
96+
if <void*>delivery_state == NULL:
97+
wrapped = None
98+
@@ -114,7 +114,7 @@ cdef void on_message_send_complete(void* context, c_message_sender.MESSAGE_SEND_
99+
context_obj._on_message_sent(context_obj, send_result, delivery_state=wrapped)
100+
101+
102+
-cdef void on_message_sender_state_changed(void* context, c_message_sender.MESSAGE_SENDER_STATE_TAG new_state, c_message_sender.MESSAGE_SENDER_STATE_TAG previous_state):
103+
+cdef void on_message_sender_state_changed(void* context, c_message_sender.MESSAGE_SENDER_STATE_TAG new_state, c_message_sender.MESSAGE_SENDER_STATE_TAG previous_state) noexcept:
104+
if context != NULL:
105+
context_pyobj = <PyObject*>context
106+
if context_pyobj.ob_refcnt == 0: # context is being garbage collected, skip the callback
107+
--
108+
2.43.0
109+

SPECS-EXTENDED/python-uamqp/python-uamqp.spec

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,26 @@ Distribution: Azure Linux
55

66
Name: python-%{srcname}
77
Version: 1.5.1
8-
Release: 3%{?dist}
8+
Release: 4%{?dist}
99
Summary: AMQP 1.0 client library for Python
1010

1111
License: MIT
1212
URL: https://github.com/Azure/azure-uamqp-python
1313
Source0: %{url}/archive/v%{version}/%{srcname}-%{version}.tar.gz#/azure-%{srcname}-python-%{version}.tar.gz
1414
# Fix build with GCC 11
15-
Patch1: %{name}-treat-warnings-as-warnings.patch
16-
15+
Patch0: %{name}-treat-warnings-as-warnings.patch
16+
Patch1: cython3.0-support.patch
17+
Patch2: u_OpenSSL3.0-support.patch
1718
BuildRequires: cmake
1819
BuildRequires: gcc-c++
1920
BuildRequires: openssl-devel
2021
BuildRequires: python3-devel
21-
BuildRequires: %{py3_dist cython}
22-
BuildRequires: %{py3_dist setuptools}
22+
BuildRequires: python3-Cython
23+
BuildRequires: python3-setuptools
2324

2425
%if 0%{?with_check}
25-
BuildRequires: %{py3_dist certifi}
26-
BuildRequires: %{py3_dist pytest-asyncio}
26+
BuildRequires: python3-certifi
27+
BuildRequires: python3-pytest-asyncio
2728
BuildRequires: python3-pip
2829
%endif
2930

@@ -67,6 +68,9 @@ pip3 install pytest six
6768

6869

6970
%changelog
71+
* Wed Nov 12 2025 Akhila Guruju <v-guakhila@microsoft.com> - 1.5.1-4
72+
- Add cython3.0-support.patch & u_OpenSSL3.0-support.patch to fix build
73+
7074
* Fri Apr 29 2022 Muhammad Falak <mwani@microsoft.com> - 1.5.1-3
7175
- Drop BR on pytest, six & pip install deps to enable ptest
7276

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
From d9fca37b925e8087e26e4fd15924b02445df3df3 Mon Sep 17 00:00:00 2001
2+
From: Kashif Khan <kashifkhan@microsoft.com>
3+
Date: Fri, 27 Jan 2023 14:32:34 -0600
4+
Subject: [PATCH] update c module for openssl 3
5+
6+
Upstream Patch Reference: https://github.com/Azure/azure-uamqp-python/commit/d9fca37b925e8087e26e4fd15924b02445df3df3.patch
7+
---
8+
.../deps/azure-c-shared-utility/CMakeLists.txt | 12 ++++++++++++
9+
.../azure-c-shared-utility/adapters/tlsio_openssl.c | 4 ++--
10+
.../azure-c-shared-utility/adapters/x509_openssl.c | 2 +-
11+
3 files changed, 15 insertions(+), 3 deletions(-)
12+
13+
diff --git a/src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/CMakeLists.txt b/src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/CMakeLists.txt
14+
index 5101951..87bff19 100644
15+
--- a/src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/CMakeLists.txt
16+
+++ b/src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/CMakeLists.txt
17+
@@ -448,6 +448,18 @@ endif()
18+
FILE(GLOB aziotsharedutil_md_files "devdoc/*.md")
19+
SOURCE_GROUP(devdoc FILES ${aziotsharedutil_md_files})
20+
21+
+# Add ignore deprecated functions so we may use 1.1.1 APIs
22+
+# in OpenSSL 3
23+
+if(LINUX)
24+
+ set_property(
25+
+ SOURCE
26+
+ ${CMAKE_CURRENT_LIST_DIR}/adapters/tlsio_openssl.c
27+
+ ${CMAKE_CURRENT_LIST_DIR}/adapters/x509_openssl.c
28+
+ PROPERTY COMPILE_OPTIONS
29+
+ -Wno-deprecated-declarations
30+
+ )
31+
+endif()
32+
+
33+
#this is the product (a library)
34+
add_library(aziotsharedutil ${source_c_files} ${source_h_files} ${aziotsharedutil_md_files})
35+
setTargetBuildProperties(aziotsharedutil)
36+
diff --git a/src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/adapters/tlsio_openssl.c b/src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/adapters/tlsio_openssl.c
37+
index 4a3df84..1832994 100644
38+
--- a/src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/adapters/tlsio_openssl.c
39+
+++ b/src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/adapters/tlsio_openssl.c
40+
@@ -953,7 +953,7 @@ static int add_certificate_to_store(TLS_IO_INSTANCE* tls_io_instance, const char
41+
}
42+
else
43+
{
44+
-#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && (OPENSSL_VERSION_NUMBER < 0x20000000L)
45+
+#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
46+
const BIO_METHOD* bio_method;
47+
#else
48+
BIO_METHOD* bio_method;
49+
@@ -1238,7 +1238,7 @@ void tlsio_openssl_deinit(void)
50+
{
51+
openssl_dynamic_locks_uninstall();
52+
openssl_static_locks_uninstall();
53+
-#if (OPENSSL_VERSION_NUMBER >= 0x00907000L) && (OPENSSL_VERSION_NUMBER < 0x20000000L) && (FIPS_mode_set)
54+
+#if (OPENSSL_VERSION_NUMBER >= 0x00907000L) && (FIPS_mode_set)
55+
FIPS_mode_set(0);
56+
#endif
57+
CRYPTO_set_locking_callback(NULL);
58+
diff --git a/src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/adapters/x509_openssl.c b/src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/adapters/x509_openssl.c
59+
index 5a9e5ac..12107ff 100644
60+
--- a/src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/adapters/x509_openssl.c
61+
+++ b/src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/adapters/x509_openssl.c
62+
@@ -75,7 +75,7 @@ static int load_certificate_chain(SSL_CTX* ssl_ctx, const char* certificate)
63+
// certificates.
64+
65+
/* Codes_SRS_X509_OPENSSL_07_006: [ If successful x509_openssl_add_ecc_credentials shall to import each certificate in the cert chain. ] */
66+
-#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && (OPENSSL_VERSION_NUMBER < 0x20000000L)
67+
+#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
68+
SSL_CTX_clear_extra_chain_certs(ssl_ctx);
69+
#else
70+
if (ssl_ctx->extra_certs != NULL)
71+
--
72+
2.43.2
73+

0 commit comments

Comments
 (0)