From 4de7bf20c05b249d967048f9e28f7d23264fba4b Mon Sep 17 00:00:00 2001 From: Branch Vincent Date: Sun, 4 Feb 2024 23:45:13 -0800 Subject: [PATCH] replace distutils for python 3.12 Python 3.12 has removed distutils: https://docs.python.org/3.12/whatsnew/3.12.html#removed Updated comments and minimum version to match Darwin kernel based on @branchevincent's explanation at https://github.com/dlenski/vpn-slice/pull/149#discussion_r1496830990 Signed-off-by: Daniel Lenski --- vpn_slice/__main__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vpn_slice/__main__.py b/vpn_slice/__main__.py index 7b90072..a38bec1 100755 --- a/vpn_slice/__main__.py +++ b/vpn_slice/__main__.py @@ -41,19 +41,21 @@ def get_default_providers(): prep = CheckTunDevProvider, ) elif platform.startswith('darwin'): - from distutils.version import LooseVersion from platform import release from .dnspython import DNSPythonProvider from .mac import BSDRouteProvider, MacSplitDNSProvider, PfFirewallProvider, PsProvider from .posix import PosixHostsFileProvider + parsed_release = tuple(int(d) if d.isdigit() else 0 for d in release().split(".")) return dict( process=PsProvider, route=BSDRouteProvider, dns=DNSPythonProvider or DigProvider, hosts=PosixHostsFileProvider, domain_vpn_dns=MacSplitDNSProvider, - firewall = PfFirewallProvider if release() >= LooseVersion('10.6') else None, + # PF firewall was released with MacOS 10.6 Snow Leopard (= Darwin kernel 10.0) + # https://en.wikipedia.org/wiki/Mac_OS_X_Snow_Leopard#Release_history + firewall = PfFirewallProvider if parsed_release >= (10, 0) else None, ) elif platform.startswith('freebsd'): from .dnspython import DNSPythonProvider