Files
macports-ports/python/py-pathtools/files/fix-support-py312.diff
Kirill A. Korinsky c0c9c2d5df py-pathtools: add py312
2023-12-17 21:06:59 -05:00

32 lines
961 B
Diff

--- setup.py
+++ setup.py
@@ -22,12 +22,25 @@
# THE SOFTWARE.
import os
-import imp
+import importlib.util
+import importlib.machinery
from setuptools import setup
PKG_DIR = 'pathtools'
-version = imp.load_source('version',
- os.path.join(PKG_DIR, 'version.py'))
+
+# From: https://docs.python.org/3.12/whatsnew/3.12.html#removed
+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
+
+version = load_source('version',
+ os.path.join(PKG_DIR, 'version.py'))
def read_file(filename):
"""