Compare commits

...

8 Commits

Author SHA1 Message Date
efc6eb3044 [+] py3.8 support 2025-05-19 11:26:03 +03:00
1ea733814b [!] Fix windowed mode 2025-04-01 15:46:46 +03:00
b33b067e75 [+] Window support 2025-04-01 15:18:01 +03:00
6b9094abf5 [!] fix add-data 2025-03-26 12:58:09 +03:00
605919d1c8 [!!] fix build 2025-03-24 17:24:10 +03:00
2d0fca9845 [+] splash support 2025-03-24 17:01:43 +03:00
ed5ee5dad1 [>] icon to metadata 2025-03-24 02:19:32 +03:00
176805ec41 [+] build_args 2025-03-24 02:18:27 +03:00
4 changed files with 50 additions and 19 deletions

View File

@@ -8,20 +8,36 @@ from .patchers import patch_core_build
from .patchers import patch_metadata from .patchers import patch_metadata
from .config import * from .config import *
product_name = "None" # Автоматически берется из metadata product_name = "None" # Читается из metadata
icon = "" # Читается из metadata
splash = "" # Читается из metadata
def get_pyinstaller_cmd(): def get_pyinstaller_cmd():
splash_str = ""
uac_admin = ""
dwt = ""
windows_mode = "--console"
if windowed[0]:
windows_mode = "-w"
add_data = [f'--add-data {path_fix + d}' for d in data]
if splash:
splash_str = f' --splash {path_fix + splash} '
if add_data:
add_data = f" {' '.join(add_data)}"
if disable_windowed_traceback:
dwt = " --disable-windowed-traceback "
if admin:
uac_admin = " --uac-admin "
pyinstaller_cmd = \ pyinstaller_cmd = \
(f'pyinstaller --noconfirm --onedir --console --clean ' (f'pyinstaller --noconfirm --onedir {windows_mode} --clean '
f'--icon {path_fix + icon} --version-file {path_fix + metadata_path_txt} --name {product_name}' f'--icon {path_fix + icon} --version-file {path_fix + metadata_path_txt}'
f'{"".join([f' --add-data {path_fix + d}' for d in data])} ' f'{splash_str}{add_data}{dwt}{uac_admin}'
f'--workpath {workpath} --distpath {distpath} --specpath {specpath} ' f'--workpath {workpath} --distpath {distpath} --specpath {specpath} '
f'--contents-directory {contents_directory} --optimize {optimize} ' f'--contents-directory {contents_directory} --optimize {optimize} '
f'{"--disable-windowed-traceback " if disable_windowed_traceback else ""}' f'--name {product_name} {main}').split(" ")
f'{"--uac-admin " if admin else ""}' pyinstaller_cmd = [x for x in pyinstaller_cmd if x]
f'{main}')
logger.info(f"execute: {pyinstaller_cmd}") logger.info(f"execute: {pyinstaller_cmd}")
return pyinstaller_cmd.split(" ") return pyinstaller_cmd
def calculate_sha256(file_path): def calculate_sha256(file_path):
sha256_hash = hashlib.sha256() sha256_hash = hashlib.sha256()
@@ -101,9 +117,9 @@ def cleanup():
os.makedirs(build_dir, exist_ok=True) os.makedirs(build_dir, exist_ok=True)
def build(): def build():
global product_name global product_name, icon, splash
new_ver = patch_core_build() new_ver = patch_core_build()
old_ver, product_name = patch_metadata(*new_ver) old_ver, product_name, icon, splash = patch_metadata(*new_ver)
logger.info("Building...") logger.info("Building...")
# subprocess.run(['auto-py-to-exe', '--config', build_json_path], shell=True) # subprocess.run(['auto-py-to-exe', '--config', build_json_path], shell=True)
subprocess.run(get_pyinstaller_cmd()) subprocess.run(get_pyinstaller_cmd())
@@ -122,7 +138,7 @@ def build():
new_ver = f"{new_ver[0]}.{new_ver[1]}.{new_ver[2]}.{new_ver[3]}" new_ver = f"{new_ver[0]}.{new_ver[1]}.{new_ver[2]}.{new_ver[3]}"
if diff: if diff:
update_dir = generate_patch(old_ver, new_ver, diff) update_dir = generate_patch(old_ver, new_ver, diff)
logger.info(f" - diffs in: {update_dir.split("/")[-1]}") logger.info(f" - diffs in: {update_dir.split('/')[-1]}")
logger.info(" - saving..") logger.info(" - saving..")
save_sha256(new_sha) save_sha256(new_sha)

View File

@@ -13,11 +13,12 @@ build_json_path = './win/build.json'
# Настройки сборки # Настройки сборки
main = 'src/main.py' main = 'src/main.py'
icon = "./src/resources/ico/icon_dark.ico" product_name = "None" # Читается из metadata
data = [ icon = "" # Читается из metadata
"./src/resources;resources/", # Папка с ресурсами для UI и т.д. splash = "" # Читается из metadata
"./.venv/Lib/site-packages/customtkinter;customtkinter/", # Папка с библиотекой customtkinter data = []
]
windowed = [False]
path_fix = os.path.abspath(os.path.dirname(__file__)) + "/../../" path_fix = os.path.abspath(os.path.dirname(__file__)) + "/../../"

View File

@@ -13,6 +13,8 @@ def patch_metadata(major, minor, patch, build_i):
metadata = yaml.load(file) metadata = yaml.load(file)
logger.info(" - metadata loaded") logger.info(" - metadata loaded")
product_name = metadata['ProductName'] product_name = metadata['ProductName']
icon = metadata['Icon']
splash = metadata.get("Splash")
old_data = metadata['Version'] old_data = metadata['Version']
logger.info(f" - current version: {old_data}") logger.info(f" - current version: {old_data}")
logger.info(f" - patched version: {major}.{minor}.{patch}.{build_i}") logger.info(f" - patched version: {major}.{minor}.{patch}.{build_i}")
@@ -23,4 +25,4 @@ def patch_metadata(major, minor, patch, build_i):
logger.info(" - creating version file") logger.info(" - creating version file")
subprocess.run(['create-version-file', metadata_path, '--outfile', metadata_path_txt]) subprocess.run(['create-version-file', metadata_path, '--outfile', metadata_path_txt])
logger.info("Ready") logger.info("Ready")
return old_data, product_name return old_data, product_name, icon, splash

16
main.py
View File

@@ -1,12 +1,24 @@
import sys import sys
from dist_scripts import build from dist_scripts import config
from dist_scripts import patchers
mode = "build" mode = "build"
build_args = ""
args = sys.argv args = sys.argv
if len(args) > 1: if len(args) > 1:
mode = args[1] mode = args[1]
if len(args) > 2:
build_args = args[2:]
if "ctk" in build_args:
config.data.append("./.venv/Lib/site-packages/customtkinter;customtkinter/") # Папка с библиотекой customtkinter
if "res" in build_args:
config.data.append("./src/resources;resources/") # Папка с ресурсами для UI и т.д.
if "w" in build_args:
config.windowed[0] = True
from dist_scripts import build
from dist_scripts import patchers
if __name__ == '__main__': if __name__ == '__main__':
if mode == "build": if mode == "build":