From 96cab1dddba1d01eb4f604ea77e7b4b814f4e3fb Mon Sep 17 00:00:00 2001 From: halliday2023 Date: Wed, 14 Feb 2024 10:56:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=93=E5=8C=85=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DTCPyinstaller.py | 15 ++++++++++++++- release.py | 2 +- tox.ini | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/DTCPyinstaller.py b/DTCPyinstaller.py index 4779fc5..39cbc13 100644 --- a/DTCPyinstaller.py +++ b/DTCPyinstaller.py @@ -1,12 +1,25 @@ # -*- coding: utf-8 -*- import re import sys - +import shutil from PyInstaller.__main__ import run +from pathlib import Path # python DTCPyinstaller.py --clean -y DataCreating_Click.spec +def clean(): + # 清理目录 + path = Path(__file__) + build_dir = path.parent / "build" + dist_dir = path.parent / "dist" + if build_dir.exists(): + shutil.rmtree(build_dir) + if dist_dir.exists(): + shutil.rmtree(dist_dir) + + if __name__ == '__main__': + clean() sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$','',sys.argv[0]) sys.exit(run()) diff --git a/release.py b/release.py index c048890..95b38ca 100644 --- a/release.py +++ b/release.py @@ -55,7 +55,7 @@ def _copytree(src, dst, ignore=None): def _zip_file(target_dir): root_dir = os.path.dirname(target_dir) os.chdir(root_dir) - shutil.make_archive(os.path.basename(target_dir), format="gztar", + shutil.make_archive(os.path.basename(target_dir), format="zip", base_dir=os.path.basename(target_dir)) diff --git a/tox.ini b/tox.ini index f90f92f..c720661 100644 --- a/tox.ini +++ b/tox.ini @@ -25,7 +25,7 @@ deps = commands = # 先调用pyinstaller打包 - {envpython} {toxinidir}/DTCPyinstaller.py --clean -y DataCreating_Click.spec + {envpython} {toxinidir}/DTCPyinstaller.py DataCreating_Click.spec # 整体打包 {envpython} {toxinidir}/release.py {envdir} {toxinidir}/dist/dataCreatingGUI {toxinidir}/dist/dataCreatingGUI_v1.0.0 {toxinidir}