Skip to content
Merged

Dev #23

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 40 additions & 3 deletions .github/workflows/dev_package_and_upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ on:
- 'package/nuitka_config.yml'

jobs:
package-and-upload:
package-and-release:
runs-on: windows-latest
env:
PYTHON_VERSION: 3.10
NUITKA_CACHE_DIR: ${{ github.workspace }}/nuitka-cache

# 添加必要的权限
permissions:
Expand All @@ -23,17 +26,42 @@ jobs:

- name: Checkout code
uses: actions/checkout@v4



- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

python-version: ${{ env.PYTHON_VERSION }}

- name: Cache UPX
id: cache-upx
uses: actions/cache@v4
with:
path: upx
key: ${{ runner.os }}-${{ runner.arch }}-upx-v5.0.1
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-upx-

- name: UPX Setup
if: ${{ steps.cache-upx.outputs.cache-hit != 'true' }
run: |
mkdir upx
curl -o upx/upx.exe https://assets.ksable.top/github/upx/upx/v5.0.1/windows-amd64/upx.exe

- name: get pip cache dir
id: pip-cache-dir
run: echo "pip-cache-dir=$(pip cache dir)" >> $env:GITHUB_OUTPUT

- name: pip cache
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache-dir.outputs.dir }} # pip缓存路径
key: ${{ runner.os }}-${{ runner.arch }}-pip-${{ hashFiles('package/nuitka_build.py') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-pip- # 后备恢复键(当精确键不存在时,使用最近的缓存)


- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -53,6 +81,15 @@ jobs:
# # 设置控制台编码为UTF-8
# chcp.com 65001

- name: Cache Nuitka cache directory
uses: actions/cache@v4
with:
path: ${{ env.NUITKA_CACHE_DIR }}
key: nuitka-${{ runner.os }}-${{ runner.arch }}-python-${{ env.PYTHON_VERSION }}-nuitka-${{ hashFiles('package/nuitka_build.py') }}
restore-keys: |
nuitka-${{ runner.os }}-${{ runner.arch }}-python-${{ env.PYTHON_VERSION }}-
nuitka-${{ runner.os }}-${{ runner.arch }}-

- name: Run packaging script
run: |
# 设置Python使用UTF-8编码
Expand Down
2 changes: 1 addition & 1 deletion novel_crawler/novel_crawler_v.25.07.08.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def download_chapter(chapter_info, progress, task_id, chapter_count):

# 主函数开始
def main():
print_header("小说爬虫工具\n版本 v.25.07.07")
print_header("小说爬虫工具")

if debug:
logger.debug("Debug模式已开启")
Expand Down
Binary file added package/assets/favicon.ico
Binary file not shown.
31 changes: 17 additions & 14 deletions package/nuitka_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ def main():

print(f"当前操作系统: {Machine} {arrch}")
print(f"平台详情: {platform.platform()}")
print("CPU核心数:", os.cpu_count())
print(f"Python版本: {sys.version}")

# 解析命令行参数
parser = argparse.ArgumentParser(description='Nuitka打包脚本')
parser.add_argument('config', help='配置文件路径')
args = parser.parse_args()

cpu_count=os.cpu_count()
# 读取配置文件
with open(args.config, 'r', encoding='utf-8') as f:
config = yaml.safe_load(f)
Expand Down Expand Up @@ -92,6 +93,7 @@ def main():
'--onefile', # 单文件
'--standalone',
'--mingw64',
f'--jobs={os.cpu_count()}', # 多线程
# '--mode',
'--assume-yes-for-downloads', #自动下载外部代码
# '--show-memory'
Expand All @@ -106,22 +108,23 @@ def main():
if icon:
icon_path = base_dir / icon
if icon_path.exists():
cmd.extend(['--windows-icon-from-ico=icon.ico', str(icon_path)])
cmd.append(f'--windows-icon-from-ico={str(icon_path)}')
else:
print(f"警告: 图标文件不存在 {icon_path}")

# if arrch == "ARM64":
# print("UPX不支持当前架构")
# else:
# if use_upx:
# if upx_dir.exists():
# cmd.append('--plugin-enable=upx')
# cmd.extend(['--upx-binary', str(upx_dir)])
# print(f"使用UPX压缩: {upx_dir}")
# else:
# print(f"警告: UPX目录不存在 {upx_dir}")
# else:
# print("不使用UPX压缩")

if arrch == "ARM64":
print("UPX不支持当前架构")
else:
if use_upx:
if upx_dir.exists():
cmd.append('--plugin-enable=upx')
cmd.append(f'--upx-binary={str(upx_dir)}')
print(f"使用UPX压缩: {upx_dir}")
else:
print(f"警告: UPX目录不存在 {upx_dir}")
else:
print("不使用UPX压缩")

# 添加主Python文件
t_file = str(uuid.uuid4()) + ".py"
Expand Down
26 changes: 14 additions & 12 deletions package/nuitka_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
'rich',
'Pillow'
]
# upx: true
upx: true
# onefile: 2 # 0:文件夹 1:单文件 2:两者
icon:
icon: package\assets\favicon.ico
windows-disable-console: False
distpath: 'dist'
timeout: 2700
Expand All @@ -22,11 +22,12 @@
install-requirements: [
'keyboard',
'configparser',
'pywin32'
'pywin32',
'psutil'
]
# upx: true
upx: true
# onefile: 1
icon:
icon: package\assets\favicon.ico
windows-disable-console: False
distpath: 'dist'
timeout: 2700
Expand All @@ -41,9 +42,9 @@
'tabulate',
'mutagen'
]
# upx: true
upx: true
# onefile: 1
icon:
icon: package\assets\favicon.ico
windows-disable-console: False
distpath: 'dist'
timeout: 2700
Expand All @@ -55,9 +56,9 @@
install-requirements: [
'pyftpdlib'
]
# upx: true
upx: true
# onefile: 1
icon:
icon: package\assets\favicon.ico
windows-disable-console: False
distpath: 'dist'
timeout: 2700
Expand All @@ -67,11 +68,12 @@
version: 'v.25.05.02'
python-file: 'sunrise_sunset_info\sunrise_sunset_info_v.25.05.02.py'
install-requirements: [
'pyftpdlib'
'pyftpdlib',
'astropy'
]
# upx: true
upx: true
# onefile: 1 # 0:文件夹 1:单文件 2:两者
icon:
icon: package\assets\favicon.ico
windows-disable-console: False
distpath: 'dist'
timeout: 2700
Expand Down
2 changes: 1 addition & 1 deletion sunrise_sunset_info/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
安装第三方库

```bash
pip install pyftpdlib
pip install pyftpdlib astropy
```

运行
Expand Down
3 changes: 2 additions & 1 deletion 键盘监听/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
keyboard
configparser
pywin32
pywin32
psutil