File ibus-cangjie-py312.patch of Package ibus-cangjie
Index: ibus-cangjie-2.4/py-compile
===================================================================
--- ibus-cangjie-2.4.orig/py-compile
+++ ibus-cangjie-2.4/py-compile
@@ -116,7 +116,12 @@ else
fi
$PYTHON -c "
-import sys, os, py_compile, imp
+import sys, os, py_compile
+
+if sys.version_info[0] == 3 and sys.version_info[1] >= 12:
+ import importlib
+else:
+ import imp
files = '''$files'''
@@ -129,15 +134,22 @@ for file in files.split():
continue
sys.stdout.write(file)
sys.stdout.flush()
- if hasattr(imp, 'get_tag'):
- py_compile.compile(filepath, imp.cache_from_source(filepath), path)
+ if sys.version_info[0] == 3 and sys.version_info[1] >= 12 and hasattr(importlib.util, 'cache_from_source'):
+ py_compile.compile(filepath, importlib.util.cache_from_source(filepath), path)
+ elif hasattr(imp, 'get_tag'):
+ py_compile.compile(filepath, imp.cache_from_source(filepath), path)
else:
py_compile.compile(filepath, filepath + 'c', path)
sys.stdout.write('\n')" || exit $?
# this will fail for python < 1.5, but that doesn't matter ...
$PYTHON -O -c "
-import sys, os, py_compile, imp
+import sys, os, py_compile
+
+if sys.version_info[0] == 3 and sys.version_info[1] >= 12:
+ import importlib
+else:
+ import imp
# pypy does not use .pyo optimization
if hasattr(sys, 'pypy_translation_info'):
@@ -153,8 +165,10 @@ for file in files.split():
continue
sys.stdout.write(file)
sys.stdout.flush()
- if hasattr(imp, 'get_tag'):
- py_compile.compile(filepath, imp.cache_from_source(filepath, False), path)
+ if sys.version_info[0] == 3 and sys.version_info[1] >= 12 and hasattr(importlib.util, 'cache_from_source'):
+ py_compile.compile(filepath, importlib.util.cache_from_source(filepath, False), path)
+ elif hasattr(imp, 'get_tag'):
+ py_compile.compile(filepath, imp.cache_from_source(filepath, False), path)
else:
py_compile.compile(filepath, filepath + 'o', path)
sys.stdout.write('\n')" 2>/dev/null || :