Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken CI due to broken macOS tests #548

Merged
merged 6 commits into from Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGES.rst
@@ -1,3 +1,14 @@
v23.3.0
-------

* #529: macOS backend is no longer viable if the API module
cannot be loaded. Prevents "symbol not found" errors on
macOS 11 (Big Sur) and later when a "universal2" binary
is not used (available for Python 3.8.7 and later).

* #547: Tests no longer attempt to run macOS backends even
on macOS when the backend is non-viable.

v23.2.2
-------

Expand Down
7 changes: 7 additions & 0 deletions README.rst
Expand Up @@ -54,6 +54,13 @@ install dbus-python as a system package.

.. _dbus-python: https://gitlab.freedesktop.org/dbus/dbus-python

Compatibility - macOS
=====================

macOS keychain support macOS 11 (Big Sur) and later requires Python 3.8.7
or later with the "universal2" binary. See
`#525 <https://github.com/jaraco/keyring/issues/525>`_ for details.

Using Keyring
=============

Expand Down
21 changes: 18 additions & 3 deletions conftest.py
@@ -1,8 +1,23 @@
import platform
import ctypes

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

if platform.system() != 'Darwin':
collect_ignore.append('keyring/backends/macOS/api.py')

def macos_api_ignore():
"""
Starting with macOS 11, the security API becomes
non-viable except on universal2 binaries.

Ref #525.
"""

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())

collect_ignore.append('keyring/devpi_client.py')
2 changes: 2 additions & 0 deletions keyring/backends/macOS/__init__.py
Expand Up @@ -28,6 +28,8 @@ def priority(cls):
"""
if platform.system() != 'Darwin':
raise RuntimeError("macOS required")
if 'api' not in globals():
raise RuntimeError("Security API unavailable")
return 5

def set_password(self, service, username, password):
Expand Down
14 changes: 6 additions & 8 deletions tests/backends/test_macOS.py
@@ -1,16 +1,14 @@
import sys

import pytest

import keyring
from keyring.testing.backend import BackendBasicTests
from keyring.backends import macOS


def is_osx_keychain_supported():
return sys.platform in ('mac', 'darwin')


@pytest.mark.skipif(not is_osx_keychain_supported(), reason="Needs macOS")
class TestOSXKeychain(BackendBasicTests):
@pytest.mark.skipif(
not keyring.backends.macOS.Keyring.viable,
reason="macOS backend not viable",
)
class Test_macOSKeychain(BackendBasicTests):
def init_keyring(self):
return macOS.Keyring()