Skip to content

Commit eab42e4

Browse files
committed
Use presence of Security.SecItemAdd to detect viable macOS API. Ref #529.
1 parent 73f27cb commit eab42e4

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

conftest.py

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import sys
2-
import platform
1+
import ctypes
32

43
collect_ignore = ["hook-keyring.backend.py"]
54

@@ -12,16 +11,11 @@ def macos_api_ignore():
1211
Ref #525.
1312
"""
1413

15-
def make_ver(string):
16-
return tuple(map(int, string.split('.')))
17-
18-
release, _, _ = platform.mac_ver()
19-
20-
return (
21-
platform.system() != 'Darwin'
22-
or make_ver(release) > (11,)
23-
and sys.version_info < (3, 8, 7)
24-
)
14+
try:
15+
ctypes.CDLL(ctypes.util.find_library('Security')).SecItemAdd
16+
return False
17+
except Exception:
18+
return True
2519

2620

2721
collect_ignore.extend(['keyring/backends/macOS/api.py'] * macos_api_ignore())

0 commit comments

Comments
 (0)