mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
feat: 新增 Python 3.14t 自由线程镜像 (#6434)
* fix(resource): select free-threaded extension ABI * chore(deps): require moviepilot-rust 0.2.9 * perf: add free-threaded runtime comparison * feat: add free-threaded runtime profile * chore(deps): require moviepilot-rust 0.3.0 * test: isolate system endpoint import graph * fix(docker): preserve runtime profile during recovery * feat(runtime): expose active GIL state * feat(plugin): log GIL fallback attribution * test: refresh runtime observability dependency baseline * fix(plugin): validate the active uv runtime profile * test(runtime): expand free-threaded benchmark evidence * docs(runtime): define v3t governance gates * test(runtime): separate rust benchmark modes * docs: sync free-threaded architecture baseline * perf: add PostgreSQL driver comparison * docs(runtime): record final free-threaded evidence * fix(runtime): converge dual-profile dependency verification * fix(runtime): scope Python 3.14 warning filter * fix(runtime): match actual oss2 syntax warning * docs(runtime): refresh free-threaded benchmark evidence * test(architecture): refresh runtime dependency baseline * ci: skip unused Trivy Java database * build: exclude local verification artifacts * docs(runtime): refresh PostgreSQL driver benchmarks * docs(runtime): record plugin restore acceptance * docs(runtime): record amd64 candidate acceptance * ci: pin beta image publisher action * test(architecture): merge runtime dependency baseline * feat(runtime): expose Python GIL status * docs(runtime): document Python runtime status fields
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
import sysconfig
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
@@ -17,6 +18,16 @@ def is_frozen() -> bool:
|
||||
return bool(getattr(sys, "frozen", False))
|
||||
|
||||
|
||||
def is_free_threaded_runtime() -> bool:
|
||||
"""判断当前解释器是否为 CPython free-threaded 构建。"""
|
||||
return sysconfig.get_config_var("Py_GIL_DISABLED") == 1
|
||||
|
||||
|
||||
def is_gil_enabled() -> bool:
|
||||
"""返回当前 CPython 进程是否实际启用了 GIL。"""
|
||||
return sys._is_gil_enabled()
|
||||
|
||||
|
||||
def is_windows() -> bool:
|
||||
"""判断当前操作系统是否为 Windows。"""
|
||||
return os.name == "nt"
|
||||
|
||||
+13
-7
@@ -4,19 +4,25 @@ import random
|
||||
import re
|
||||
from typing import Generator, List, Optional, Union
|
||||
|
||||
from jieba_next import cut as jieba_next_cut
|
||||
from zhconv_rs import zhconv as _zhconv # pylint: disable=no-name-in-module
|
||||
import moviepilot_rust
|
||||
|
||||
from app.foundation.environment import is_free_threaded_runtime
|
||||
|
||||
if is_free_threaded_runtime():
|
||||
_zhconv = moviepilot_rust.zhconv_fast
|
||||
else:
|
||||
import zhconv_rs
|
||||
|
||||
_zhconv = zhconv_rs.zhconv
|
||||
|
||||
|
||||
def cut(text: str, HMM: bool = True, cut_all: bool = False) -> list[str]:
|
||||
"""
|
||||
使用 jieba-next 执行中文分词,并兼容 jieba.cut 的常用参数名。
|
||||
"""
|
||||
return list(jieba_next_cut(text, HMM=HMM, cut_all=cut_all))
|
||||
"""通过统一原生入口执行中文分词。"""
|
||||
return moviepilot_rust.jieba_cut(text, hmm=HMM, cut_all=cut_all)
|
||||
|
||||
|
||||
def convert(text: str, target: str) -> str:
|
||||
"""使用 zhconv-rs 执行中文简繁转换,并隔离第三方包的函数名差异。"""
|
||||
"""通过统一入口执行 MediaWiki 中文简繁转换。"""
|
||||
return _zhconv(text, target)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user