This commit is contained in:
New Future
2025-06-02 17:40:48 +00:00
committed by GitHub
parent e5c3bb9e94
commit 9ed9223750
5 changed files with 46 additions and 8 deletions
+1 -1
View File
@@ -1 +1 @@
python3 -m nuitka run.py --mode=onefile --output-dir=./dist --no-deployment-flag=self-execution --output-filename=ddns --remove-output --include-module=dns.dnspod --include-module=dns.alidns --include-module=dns.dnspod_com --include-module=dns.dnscom --include-module=dns.cloudflare --include-module=dns.he --include-module=dns.huaweidns --include-module=dns.callback --product-name=DDNS --file-description="DDNS Client 自动更新域名解析到本机IP" --company-name="New Future" --copyright="https://ddns.newfuture.cc" --windows-icon-from-ico="favicon.ico" --assume-yes-for-downloads --lto=yes --nofollow-import-to=unittest,pydoc --onefile-tempdir-spec="{CACHE_DIR}/{PRODUCT}/{VERSION}"
python3 -m nuitka run.py --mode=onefile --output-dir=./dist --no-deployment-flag=self-execution --output-filename=ddns --remove-output --include-module=dns.dnspod --include-module=dns.alidns --include-module=dns.dnspod_com --include-module=dns.dnscom --include-module=dns.cloudflare --include-module=dns.he --include-module=dns.huaweidns --include-module=dns.callback --product-name=DDNS --file-description="DDNS Client 自动更新域名解析到本机IP" --company-name="New Future" --copyright="https://ddns.newfuture.cc" --windows-icon-from-ico="favicon.ico" --assume-yes-for-downloads --lto=yes --nofollow-import-to=unittest,pydoc --onefile-tempdir-spec="{CACHE_DIR}/{PRODUCT}/{VERSION}" --linux-icon=doc/img/ddns.svg
+42 -1
View File
@@ -27,11 +27,52 @@ def dedent_imports_with_blank(import_block, try_block, except_block):
return ('\n' * try_lines) + imports + ('\n' * except_lines)
def extract_pure_version(version_str):
"""
提取前4组数字并用点拼接,如 v1.2.3.beta4.5 -> 1.2.3.4
"""
import re
nums = re.findall(r'\d+', version_str)
return '.'.join(nums[:4]) if nums else "0.0.0"
def update_nuitka_version(pyfile):
"""
读取 __version__ 并替换 nuitka-project 版本号
"""
with open(pyfile, 'r', encoding='utf-8') as f:
content = f.read()
# 提取 __version__ 变量
version_match = re.search(r'__version__\s*=\s*[\'"]([^\'"]+)[\'"]', content)
if not version_match:
print(f'No __version__ found in {pyfile}')
return False
version_str = version_match.group(1)
pure_version = extract_pure_version(version_str)
# 替换 nuitka-project 行
new_content, n = re.subn(
r'(# nuitka-project: --product-version=)[^\n]*',
r'\g<1>' + pure_version,
content
)
if n > 0:
with open(pyfile, 'w', encoding='utf-8') as f:
f.write(new_content)
print(f'update nuitka-project version: {pure_version} in {pyfile}')
return True
return False
def main():
"""
遍历所有py文件并替换兼容导入
遍历所有py文件并替换兼容导入,同时更新nuitka版本号
"""
changed_files = 0
# 先处理 run.py 的 nuitka-project 版本号
update_nuitka_version(os.path.join(ROOT, "run.py"))
for dirpath, _, filenames in os.walk(ROOT):
for fname in filenames:
if fname.endswith('.py'):
+1 -1
View File
@@ -238,7 +238,7 @@ jobs:
&& dnf repolist \
&& dnf install -y gcc strace patchelf ccache gdb make python3-devel python3-zstandard python3-ordered-set
python3 -m pip install nuitka
cd /DDNS && python3 .build/remove_python2.py && .build/nuitka.cmd
cd /DDNS && python3 .build/remove_python2.py && .build/nuitka.sh
- run: ./dist/ddns || test -e config.json
- run: ./dist/ddns -h
+1 -1
View File
@@ -203,7 +203,7 @@ jobs:
&& dnf repolist \
&& dnf install -y gcc strace patchelf ccache gdb make python3-devel python3-zstandard python3-ordered-set
python3 -m pip install nuitka
cd /DDNS && python3 .build/remove_python2.py && .build/nuitka.cmd
cd /DDNS && python3 .build/remove_python2.py && .build/nuitka.sh
- run: ./dist/ddns || test -e config.json
- run: ./dist/ddns -h
+1 -4
View File
@@ -6,10 +6,7 @@ DDNS
@modified: rufengsuixing
"""
# nuitka-project-if: os.getenv("BUILD_VERSION") is not None:
# nuitka-project: --product-version=${BUILD_VERSION}
# nuitka-project-else:
# nuitka-project: --product-version=0.0.0
# nuitka-project: --product-version=0.0.0
from os import path, environ, name as os_name
from tempfile import gettempdir