Skip to content

Commit

Permalink
Drop dependency on distutils
Browse files Browse the repository at this point in the history
Introduces a simple class to represent macOS
versions. The alternative was to rely on the
"packaging" package instead, but that's an
additional dependency and overkill for one simple class.
  • Loading branch information
ronaldoussoren committed Oct 26, 2021
1 parent c7a6a11 commit 12daa01
Showing 1 changed file with 33 additions and 11 deletions.
44 changes: 33 additions & 11 deletions development-support/wheel-smoke-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# NOTE: This file is not yet complete
"""

import functools
import platform
from distutils.version import LooseVersion

import objc # noqa: F401
from AddressBook import * # noqa: F401, F403
Expand All @@ -24,49 +24,71 @@
from HIServices import * # noqa: F401, F403
from Quartz import * # noqa: F401, F403

sys_version = LooseVersion(platform.mac_ver()[0])

@functools.total_ordering
class MacVersion:
def __init__(self, version_string):
self.version_string = version_string
self.version_tuple = tuple(int(x) for x in version_string.split("."))

if sys_version >= LooseVersion("10.5"):
def __eq__(self, other):
if not isinstance(other, MacVersion):
return False

return self.version_tuple == other.version_tuple

def __lt__(self, other):
if not isinstance(other, MacVersion):
raise TypeError

return self.version_tuple < other.version_tuple

def __str__(self):
return f"<MacVersion {self.version_tuple}>"


sys_version = MacVersion(platform.mac_ver()[0])

if sys_version >= MacVersion("10.5"):
from CalendarStore import * # noqa: F401, F403
from Collaboration import * # noqa: F401, F403
from CoreText import * # noqa: F401, F403
from DictionaryServices import * # noqa: F401, F403
from FSEvents import * # noqa: F401, F403

if sys_version >= LooseVersion("10.6"):
if sys_version >= MacVersion("10.6"):
from CoreLocation import * # noqa: F401, F403
from CoreWLAN import * # noqa: F401, F403

from iTunesLibrary import * # noqa: F401, F403


if sys_version >= LooseVersion("10.7"):
if sys_version >= MacVersion("10.7"):
from AVFoundation import * # noqa: F401, F403

if sys_version >= LooseVersion("10.8"):
if sys_version >= MacVersion("10.8"):
from Accounts import * # noqa: F401, F403
from EventKit import * # noqa: F401, F403
from GameCenter import * # noqa: F401, F403

if sys_version >= LooseVersion("10.9"):
if sys_version >= MacVersion("10.9"):
from AVKit import * # noqa: F401, F403

if sys_version >= LooseVersion("10.10"):
if sys_version >= MacVersion("10.10"):
from CloudKit import * # noqa: F401, F403
from CoreBluetooth import * # noqa: F401, F403
from CryptoTokenKit import * # noqa: F401, F403
from FinderSync import * # noqa: F401, F403

if sys_version >= LooseVersion("10.11"):
if sys_version >= MacVersion("10.11"):
from Contacts import * # noqa: F401, F403
from ContactsUI import * # noqa: F401, F403

if sys_version >= LooseVersion("10.12"):
if sys_version >= MacVersion("10.12"):
from Intents import * # noqa: F401, F403
from MediaPlayer import * # noqa: F401, F403

if sys_version >= LooseVersion("10.13"):
if sys_version >= MacVersion("10.13"):
from BusinessChat import * # noqa: F401, F403
from ColorSync import * # noqa: F401, F403
from CoreML import * # noqa: F401, F403
Expand Down

0 comments on commit 12daa01

Please sign in to comment.