1{ lib
2, stdenv
3, aiohttp
4, aioresponses
5, buildPythonPackage
6, cachetools
7, cryptography
8, fetchpatch
9, fetchPypi
10, flask
11, freezegun
12, grpcio
13, mock
14, oauth2client
15, pyasn1-modules
16, pyopenssl
17, pytest-asyncio
18, pytest-localserver
19, pytestCheckHook
20, pythonOlder
21, pyu2f
22, requests
23, responses
24, rsa
25, six
26, urllib3
27}:
28
29buildPythonPackage rec {
30 pname = "google-auth";
31 version = "2.21.0";
32 format = "setuptools";
33
34 disabled = pythonOlder "3.6";
35
36 src = fetchPypi {
37 inherit pname version;
38 hash = "sha256-so6ASOV3J+fPDlvY5ydrISrvR2ZUoJURNUqoJ1O0XGY=";
39 };
40
41 patches = [
42 # Although the migration to urllib3-2.0.0 is incomplete,
43 # the discussion in the following PR has addressed the concerns.
44 # https://github.com/googleapis/google-auth-library-python/pull/1290
45 (fetchpatch {
46 name = "support-urllib3_2.patch";
47 url = "https://github.com/googleapis/google-auth-library-python/commit/9ed006d02d7c9de3e6898ee819648c2fd3367c1d.patch";
48 hash = "sha256-64g0GzZeyO8l/s1jqfsogr8pTOBbG9xfp/UeVZNA4q8=";
49 includes = [ "google/auth/transport/urllib3.py" ];
50 })
51 ];
52
53 propagatedBuildInputs = [
54 cachetools
55 pyasn1-modules
56 rsa
57 six
58 urllib3
59 ];
60
61 passthru.optional-dependencies = {
62 aiohttp = [
63 aiohttp
64 requests
65 ];
66 enterprise_cert = [
67 cryptography
68 pyopenssl
69 ];
70 pyopenssl = [
71 pyopenssl
72 ];
73 reauth = [
74 pyu2f
75 ];
76 requests = [
77 requests
78 ];
79 };
80
81 nativeCheckInputs = [
82 aioresponses
83 flask
84 freezegun
85 grpcio
86 mock
87 oauth2client
88 pytest-asyncio
89 pytest-localserver
90 pytestCheckHook
91 responses
92 ] ++ passthru.optional-dependencies.aiohttp
93 # `cryptography` is still required on `aarch64-darwin` for `tests/crypt/*`
94 ++ (if (stdenv.isDarwin && stdenv.isAarch64) then [ cryptography ] else passthru.optional-dependencies.enterprise_cert)
95 ++ passthru.optional-dependencies.reauth;
96
97 pythonImportsCheck = [
98 "google.auth"
99 "google.oauth2"
100 ];
101
102 disabledTestPaths = lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
103 # Disable tests using pyOpenSSL as it does not build on M1 Macs
104 "tests/transport/test__mtls_helper.py"
105 "tests/transport/test_requests.py"
106 "tests/transport/test_urllib3.py"
107 "tests/transport/test__custom_tls_signer.py"
108 ];
109
110 __darwinAllowLocalNetworking = true;
111
112 meta = with lib; {
113 description = "Google Auth Python Library";
114 longDescription = ''
115 This library simplifies using Google's various server-to-server
116 authentication mechanisms to access Google APIs.
117 '';
118 homepage = "https://github.com/googleapis/google-auth-library-python";
119 changelog = "https://github.com/googleapis/google-auth-library-python/blob/v${version}/CHANGELOG.md";
120 license = licenses.asl20;
121 maintainers = with maintainers; [ ];
122 };
123}