1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 fetchpatch2,
7 setuptools,
8 cython,
9 certifi,
10 cmake,
11 openssl,
12 pytestCheckHook,
13 pytest-asyncio,
14}:
15
16buildPythonPackage rec {
17 pname = "uamqp";
18 version = "1.6.11";
19 pyproject = true;
20
21 src = fetchFromGitHub {
22 owner = "Azure";
23 repo = "azure-uamqp-python";
24 tag = "v${version}";
25 hash = "sha256-HTIOHheCrvyI7DwA/UcUXk/fbesd29lvUvJ9TAeG3CE=";
26 };
27
28 patches = [
29 (fetchpatch2 {
30 name = "fix-clang16-compatibility.patch";
31 url = "https://github.com/Azure/azure-uamqp-python/commit/bd6d9ef5a8bca3873e1e66218fd09ca787b8064e.patch";
32 hash = "sha256-xtnIVjB71EPJp/QjLQWctcSDds5s6n4ut+gnvp3VMlM=";
33 })
34 ];
35
36 postPatch = lib.optionalString (stdenv.hostPlatform.isDarwin && !stdenv.hostPlatform.isx86_64) ''
37 # force darwin aarch64 to use openssl instead of applessl, removing
38 # some quirks upstream thinks they need to use openssl on macos
39 sed -i \
40 -e '/^use_openssl =/cuse_openssl = True' \
41 -e 's/\bazssl\b/ssl/' \
42 -e 's/\bazcrypto\b/crypto/' \
43 setup.py
44 sed -i \
45 -e '/#define EVP_PKEY_id/d' \
46 src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/adapters/x509_openssl.c
47 sed -z -i \
48 -e 's/OpenSSL 3\nif(LINUX)/OpenSSL 3\nif(1)/' \
49 src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/CMakeLists.txt
50 '';
51
52 build-system = [
53 cython
54 setuptools
55 ];
56
57 nativeBuildInputs = [
58 cmake
59 ];
60
61 buildInputs = [ openssl ];
62
63 dependencies = [ certifi ];
64
65 dontUseCmakeConfigure = true;
66
67 preCheck = ''
68 # remove src module, so tests use the installed module instead
69 rm -r uamqp
70 '';
71
72 nativeCheckInputs = [
73 pytestCheckHook
74 pytest-asyncio
75 ];
76
77 pythonImportsCheck = [ "uamqp" ];
78
79 meta = with lib; {
80 description = "AMQP 1.0 client library for Python";
81 homepage = "https://github.com/Azure/azure-uamqp-python";
82 license = licenses.mit;
83 maintainers = with maintainers; [ maxwilson ];
84 };
85}