From 19fdca6383647d165f2d87609504f7686a9e5e9f Mon Sep 17 00:00:00 2001 From: Haneesh Date: Thu, 22 Feb 2024 13:24:40 +0530 Subject: [PATCH] Updating setup.py to work with python 3.12 --- setup.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 6d35a62..278864e 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,20 @@ -import imp +try: + from imp import load_source +except ImportError: + import importlib.util + import importlib.machinery + + def load_source(modname, filename): + loader = importlib.machinery.SourceFileLoader(modname, filename) + spec = importlib.util.spec_from_file_location(modname, filename, loader=loader) + module = importlib.util.module_from_spec(spec) + # The module is always executed and not cached in sys.modules. + # Uncomment the following line to cache the module. + # sys.modules[module.__name__] = module + loader.exec_module(module) + return module + + import os try: @@ -16,8 +32,8 @@ README = '' CHANGES = '' -# Use imp to avoid sift/__init__.py -version_mod = imp.load_source('__tmp', os.path.join(here, 'sift/version.py')) +# Use imp/importlib to avoid sift/__init__.py +version_mod = load_source('__tmp', os.path.join(here, 'sift/version.py')) setup( name='Sift',