From ae3669c92df8769b6da9978b96fc3362114e5b1f Mon Sep 17 00:00:00 2001 From: wujiasheng03 Date: Tue, 7 Jan 2025 16:12:44 +0800 Subject: [PATCH] support python3.12&3.13, not support python3.7 --- lyrebird_bugit/template_loader.py | 10 +++++++--- setup.py | 5 +++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lyrebird_bugit/template_loader.py b/lyrebird_bugit/template_loader.py index f26b403..8971bcd 100644 --- a/lyrebird_bugit/template_loader.py +++ b/lyrebird_bugit/template_loader.py @@ -1,4 +1,4 @@ -import imp +import importlib import traceback from hashlib import md5 from pathlib import Path @@ -45,7 +45,9 @@ def template_list(): continue try: logger.debug(f'Load template {template_file}') - template = imp.load_source(template_file.stem, str(template_file)) + spec = importlib.util.spec_from_file_location(template_file.stem, str(template_file)) + template = importlib.util.module_from_spec(spec) + spec.loader.exec_module(template) template_check(template) relative_template_file_path = str(template_file).replace(str(Path.home()), '~') template_key = md5(relative_template_file_path.encode()).hexdigest() @@ -97,7 +99,9 @@ def get_template(file_path): global last_template if not last_template or last_template.__file__ != str(file_path): - last_template = imp.load_source(Path(file_path).stem, str(file_path)) + spec = importlib.util.spec_from_file_location(Path(file_path).stem, str(file_path)) + last_template = importlib.util.module_from_spec(spec) + spec.loader.exec_module(last_template) return last_template diff --git a/setup.py b/setup.py index 85ff271..b7aba6a 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name='lyrebird-bugit', - version='1.16.1', + version='1.16.2', packages=['lyrebird_bugit'], url='https://github.com/Meituan-Dianping/lyrebird-bugit', author='HBQA', @@ -18,11 +18,12 @@ zip_safe=False, classifiers=( "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "License :: OSI Approved :: MIT License", "Operating System :: MacOS", ),