--- SConscript.orig	2021-09-21 17:53:44.000000000 -0400
+++ SConscript	2023-01-20 14:35:29.526522000 -0500
@@ -20,7 +20,7 @@
 import subprocess
 import sys
 import time
-from distutils import sysconfig
+import sysconfig
 import SCons
 
 # scons does not like targets that come and go (if cleaning, if python,
@@ -243,7 +243,7 @@
 # Hosting information ends here
 
 
-PYTHON_SYSCONFIG_IMPORT = 'from distutils import sysconfig'
+PYTHON_SYSCONFIG_IMPORT = 'import sysconfig'
 
 # Utility productions
 
@@ -962,7 +962,7 @@
                         "-Wl,-compatibility_version,%s" % libgps_version,
                         "-Wl,-install_name,%s/$TARGET.srcpath" %
                         installdir('libdir', add_destdir=False)]
-    elif sys.platform.startswith('freebsd'):
+    elif sys.platform.startswith('midnightbsd'):
         # for isascii(), putenv(), nice(), strptime()
         confdefs.append('#if !defined(_XOPEN_SOURCE)')
         confdefs.append('#define _XOPEN_SOURCE 700')
@@ -1042,7 +1042,7 @@
             ncurseslibs = ['!ncurses5-config --libs --cflags']
         elif WhereIs('ncursesw5-config'):
             ncurseslibs = ['!ncursesw5-config --libs --cflags']
-        elif sys.platform.startswith('freebsd'):
+        elif sys.platform.startswith('midnightbsd'):
             ncurseslibs = ['-lncurses']
         elif (sys.platform.startswith('darwin') or
               sys.platform.startswith('openbsd') or
@@ -1062,7 +1062,7 @@
                 announce("pkg_config is confused about the state "
                          "of libusb-1.0.")
                 usbflags = []
-        elif sys.platform.startswith("freebsd"):
+        elif sys.platform.startswith("midnightbsd"):
             confdefs.append("#define HAVE_LIBUSB 1\n")
             usbflags = ["-lusb"]
         else:
@@ -1419,7 +1419,7 @@
 
 # Set up configuration for target Python
 
-PYTHON_LIBDIR_CALL = 'sysconfig.get_python_lib()'
+PYTHON_LIBDIR_CALL = 'sysconfig.get_paths()["purelib"]'
 
 PYTHON_CONFIG_NAMES = ['SO']  # Now a fairly degenerate list
 PYTHON_CONFIG_QUOTED = ["'%s'" % s for s in PYTHON_CONFIG_NAMES]
@@ -1520,7 +1520,7 @@
                                        'import sys',
                                        '"%d.%d" % sys.version_info[0:2]')
 
-        if 3 > int(sysver[0]) or 6 > int(sysver[2]):
+        if 3 > int(sysver[0]) or 6 > int(sysver[2:]):
             config.env['aiogps'] = False
             announce("WARNING: Python%s too old (need 3.6): "
                      "gps/aiogps.py will not be installed" %
