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