Skip to content

Commit

Permalink
Use presence of Security.SecItemAdd to detect viable macOS API. Ref #529
Browse files Browse the repository at this point in the history
.
  • Loading branch information
jaraco committed Nov 25, 2021
1 parent 73f27cb commit eab42e4
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions conftest.py
@@ -1,5 +1,4 @@
import sys
import platform
import ctypes

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

Expand All @@ -12,16 +11,11 @@ def macos_api_ignore():
Ref #525.
"""

def make_ver(string):
return tuple(map(int, string.split('.')))

release, _, _ = platform.mac_ver()

return (
platform.system() != 'Darwin'
or make_ver(release) > (11,)
and sys.version_info < (3, 8, 7)
)
try:
ctypes.CDLL(ctypes.util.find_library('Security')).SecItemAdd
return False
except Exception:
return True


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

0 comments on commit eab42e4

Please sign in to comment.