1{ lib
2, stdenv
3, buildPythonPackage
4, fetchFromGitHub
5, cython
6, certifi
7, CFNetwork
8, cmake
9, CoreFoundation
10, libcxxabi
11, openssl
12, Security
13, pytestCheckHook
14, pytest-asyncio
15}:
16
17buildPythonPackage rec {
18 pname = "uamqp";
19 version = "1.6.5";
20
21 src = fetchFromGitHub {
22 owner = "Azure";
23 repo = "azure-uamqp-python";
24 rev = "refs/tags/v${version}";
25 hash = "sha256-q8FxM4PBXLD5q68nrUJ+TGkui1yQJ3HHNF7jn+e+HkA=";
26 };
27
28 patches = lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [
29 ./darwin-azure-c-shared-utility-corefoundation.patch
30 ] ++ [
31 # Fix incompatible function pointer conversion error with clang 16.
32 ./clang-fix-incompatible-function-pointer-conversion.patch
33 ];
34
35 postPatch = lib.optionalString (stdenv.isDarwin && !stdenv.isx86_64) ''
36 # force darwin aarch64 to use openssl instead of applessl, removing
37 # some quirks upstream thinks they need to use openssl on macos
38 sed -i \
39 -e '/^use_openssl =/cuse_openssl = True' \
40 -e 's/\bazssl\b/ssl/' \
41 -e 's/\bazcrypto\b/crypto/' \
42 setup.py
43 sed -i \
44 -e '/#define EVP_PKEY_id/d' \
45 src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/adapters/x509_openssl.c
46 sed -z -i \
47 -e 's/OpenSSL 3\nif(LINUX)/OpenSSL 3\nif(1)/' \
48 src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/CMakeLists.txt
49 '';
50
51 nativeBuildInputs = [
52 cmake
53 cython
54 ];
55
56 buildInputs = [
57 openssl
58 ] ++ lib.optionals stdenv.isDarwin [
59 CoreFoundation
60 CFNetwork
61 Security
62 ];
63
64 propagatedBuildInputs = [
65 certifi
66 ];
67
68 LDFLAGS = lib.optionals stdenv.isDarwin [
69 "-L${lib.getLib libcxxabi}/lib"
70 ];
71
72 dontUseCmakeConfigure = true;
73
74 preCheck = ''
75 # remove src module, so tests use the installed module instead
76 rm -r uamqp
77 '';
78
79 nativeCheckInputs = [
80 pytestCheckHook
81 pytest-asyncio
82 ];
83
84 pythonImportsCheck = [
85 "uamqp"
86 ];
87
88 meta = with lib; {
89 description = "An AMQP 1.0 client library for Python";
90 homepage = "https://github.com/Azure/azure-uamqp-python";
91 license = licenses.mit;
92 maintainers = with maintainers; [ maxwilson ];
93 };
94}