diff --git a/assets/crescent_moon_3d.png b/assets/crescent_moon_3d.png deleted file mode 100644 index 83ba8ab..0000000 Binary files a/assets/crescent_moon_3d.png and /dev/null differ diff --git a/assets/crescent_moon_3d.png b/assets/crescent_moon_3d.png new file mode 120000 index 0000000..f7ab17e --- /dev/null +++ b/assets/crescent_moon_3d.png @@ -0,0 +1 @@ +../src/tchmaterial_parser/assets/crescent_moon_3d.png \ No newline at end of file diff --git a/assets/information_3d.png b/assets/information_3d.png deleted file mode 100644 index 02fbb08..0000000 Binary files a/assets/information_3d.png and /dev/null differ diff --git a/assets/information_3d.png b/assets/information_3d.png new file mode 120000 index 0000000..dc4e6c6 --- /dev/null +++ b/assets/information_3d.png @@ -0,0 +1 @@ +../src/tchmaterial_parser/assets/information_3d.png \ No newline at end of file diff --git a/assets/last_quarter_moon_3d.png b/assets/last_quarter_moon_3d.png deleted file mode 100644 index 16b4d27..0000000 Binary files a/assets/last_quarter_moon_3d.png and /dev/null differ diff --git a/assets/last_quarter_moon_3d.png b/assets/last_quarter_moon_3d.png new file mode 120000 index 0000000..efd7453 --- /dev/null +++ b/assets/last_quarter_moon_3d.png @@ -0,0 +1 @@ +../src/tchmaterial_parser/assets/last_quarter_moon_3d.png \ No newline at end of file diff --git a/assets/sun_3d.png b/assets/sun_3d.png deleted file mode 100644 index 26258a0..0000000 Binary files a/assets/sun_3d.png and /dev/null differ diff --git a/assets/sun_3d.png b/assets/sun_3d.png new file mode 120000 index 0000000..d4a5acb --- /dev/null +++ b/assets/sun_3d.png @@ -0,0 +1 @@ +../src/tchmaterial_parser/assets/sun_3d.png \ No newline at end of file diff --git a/assets/window_icon.png b/assets/window_icon.png deleted file mode 100644 index 749eaa2..0000000 Binary files a/assets/window_icon.png and /dev/null differ diff --git a/assets/window_icon.png b/assets/window_icon.png new file mode 120000 index 0000000..abb5fba --- /dev/null +++ b/assets/window_icon.png @@ -0,0 +1 @@ +../src/tchmaterial_parser/assets/window_icon.png \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index e1b32d5..c715a1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,8 @@ version = "4.0" description = "国家中小学智慧教育平台 资源下载工具" readme = "README.md" requires-python = ">=3.10" -license = {text = "MIT"} +license = "MIT" +license-files = ["LICENSE", "licenses/*.txt"] authors = [{name = "肥宅水水呀"}, {name = "晨叶梦春", email = "wuziqian211@126.com"}] dependencies = [ "pillow>=10,<13", @@ -19,10 +20,35 @@ dependencies = [ "sv-ttk>=2.6,<3", "pywin32>=306; sys_platform == 'win32'", ] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: End Users/Desktop", + "Intended Audience :: Information Technology", + "Operating System :: MacOS", + "Operating System :: Microsoft", + "Operating System :: Microsoft :: Windows :: Windows 8.1", + "Operating System :: Microsoft :: Windows :: Windows 10", + "Operating System :: Microsoft :: Windows :: Windows 11", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", + "Programming Language :: Python :: 3.15", + "Topic :: Education", + "Topic :: Utilities", + "Typing :: Typed", +] [project.urls] Homepage = "https://github.com/happycola233/tchMaterial-parser" Repository = "https://github.com/happycola233/tchMaterial-parser" +Issues = "https://github.com/happycola233/tchMaterial-parser/issues" [project.scripts] "tchmaterial-parser" = "tchmaterial_parser.app:main" @@ -33,6 +59,9 @@ package-dir = {"" = "src"} [tool.setuptools.packages.find] where = ["src"] +[tool.setuptools.package-data] +tchmaterial_parser = ["assets/*.png"] + [tool.black] line-length = 120 target-version = ["py310"] diff --git a/src/tchmaterial_parser/assets/crescent_moon_3d.png b/src/tchmaterial_parser/assets/crescent_moon_3d.png new file mode 100644 index 0000000..83ba8ab Binary files /dev/null and b/src/tchmaterial_parser/assets/crescent_moon_3d.png differ diff --git a/src/tchmaterial_parser/assets/information_3d.png b/src/tchmaterial_parser/assets/information_3d.png new file mode 100644 index 0000000..02fbb08 Binary files /dev/null and b/src/tchmaterial_parser/assets/information_3d.png differ diff --git a/src/tchmaterial_parser/assets/last_quarter_moon_3d.png b/src/tchmaterial_parser/assets/last_quarter_moon_3d.png new file mode 100644 index 0000000..16b4d27 Binary files /dev/null and b/src/tchmaterial_parser/assets/last_quarter_moon_3d.png differ diff --git a/src/tchmaterial_parser/assets/sun_3d.png b/src/tchmaterial_parser/assets/sun_3d.png new file mode 100644 index 0000000..26258a0 Binary files /dev/null and b/src/tchmaterial_parser/assets/sun_3d.png differ diff --git a/src/tchmaterial_parser/assets/window_icon.png b/src/tchmaterial_parser/assets/window_icon.png new file mode 100644 index 0000000..749eaa2 Binary files /dev/null and b/src/tchmaterial_parser/assets/window_icon.png differ diff --git a/src/tchmaterial_parser/images.py b/src/tchmaterial_parser/images.py index a8a96f0..cda6db0 100644 --- a/src/tchmaterial_parser/images.py +++ b/src/tchmaterial_parser/images.py @@ -89,7 +89,6 @@ def render_system_emoji(symbol: str, icon_size: int) -> Image.Image | None: # icon.alpha_composite(resized, ((icon_size - resized.width) // 2, (icon_size - resized.height) // 2)) return icon except Exception as e: - print_error(e) continue return None diff --git a/src/tchmaterial_parser/platform_utils.py b/src/tchmaterial_parser/platform_utils.py index ccef9a6..e8e17ca 100644 --- a/src/tchmaterial_parser/platform_utils.py +++ b/src/tchmaterial_parser/platform_utils.py @@ -9,11 +9,14 @@ def print_error(e: Exception) -> None: # 打印错误信息到控制台 traceback.print_exception(e) def resource_path(*parts: str) -> Path: # 获取源码或 PyInstaller 打包后的只读资源路径 - # 源码入口位于 src/,资源位于项目根目录;PyInstaller 则把 datas 放到 sys._MEIPASS - # 因此不能依赖当前工作目录或可执行文件所在目录,后者在单文件模式下并非资源的实际位置 - source_root = Path(__file__).resolve().parent.parent.parent # 本模块位于 src/tchmaterial_parser/ 下,上溯三级才是项目根目录 - bundle_root = Path(getattr(sys, "_MEIPASS", source_root)) - return bundle_root.joinpath(*parts) + bundle_root = getattr(sys, "_MEIPASS", None) + + if bundle_root: # PyInstaller 中数据被放在 tchmaterial_parser/assets/ + package_root = Path(bundle_root) / "tchmaterial_parser" + else: # 源码运行或 wheel 安装 + package_root = Path(__file__).resolve().parent + + return package_root.joinpath(*parts) os_name = platform.system() # 获取操作系统类型 if os_name == "Windows": # 在 Windows 操作系统下,导入 Windows 相关库 diff --git a/tchMaterial-parser.spec b/tchMaterial-parser.spec index a2eda92..3d21284 100644 --- a/tchMaterial-parser.spec +++ b/tchMaterial-parser.spec @@ -1,19 +1,17 @@ # -*- mode: python ; coding: utf-8 -*- import sys +from pathlib import Path from PyInstaller.utils.hooks import collect_data_files is_mac = sys.platform.startswith('darwin') -# sv-ttk 通过 Path(__file__).with_name() 加载主题文件,需把随包的 .tcl 与 .png 一并收集进来; -# 下面 4 个图标文件是程序运行时读取的自有资源,目标目录保持为 assets/,与源码中的相对路径一致 -data_files = collect_data_files('sv_ttk') + [ - ('assets/window_icon.png', 'assets'), - ('assets/last_quarter_moon_3d.png', 'assets'), - ('assets/sun_3d.png', 'assets'), - ('assets/crescent_moon_3d.png', 'assets'), - ('assets/information_3d.png', 'assets'), +# sv-ttk 通过 Path(__file__).with_name() 加载主题文件,需把随包的 .tcl 与 .png 一并收集进来;图标文件是程序运行时读取的自有资源 +runtime_assets = [ + (str(path), "tchmaterial_parser/assets") + for path in Path("src/tchmaterial_parser/assets").glob("*.png") ] +data_files = collect_data_files("sv_ttk") + runtime_assets a = Analysis( # 入口位于包外:PyInstaller 会把入口脚本当作 __main__ 分析,包内脚本的相对导入在此情形下不成立