BAPSicle/build/build-exe.py

50 lines
1.3 KiB
Python
Raw Permalink Normal View History

import json
2022-03-19 16:04:13 +00:00
from helpers.os_environment import isLinux
file = open('build-exe-config.json', 'r')
config = json.loads(file.read())
file.close()
2022-03-19 16:04:13 +00:00
if isLinux():
2024-03-29 16:38:10 +00:00
cmd_str = "poetry run python3 -m PyInstaller "
2022-03-19 16:04:13 +00:00
else:
2024-03-29 16:38:10 +00:00
cmd_str = "poetry run pyinstaller "
2022-03-19 16:04:13 +00:00
json_dests = ["icon_file", "clean_build"]
pyi_dests = ["icon", "clean"]
2021-04-08 21:05:25 +00:00
filename = ""
for option in config["pyinstallerOptions"]:
option_dest = option["optionDest"]
# The json is rather inconsistent :/
if option_dest in json_dests:
option_dest = pyi_dests[json_dests.index(option_dest)]
option_dest = option_dest.replace("_", "-")
if option_dest == "datas":
cmd_str += '--add-data "' + option["value"] + '" '
elif option_dest == "filenames":
filename = option["value"]
2021-04-08 21:05:25 +00:00
elif option["value"] is True:
cmd_str += "--" + str(option_dest) + " "
2021-04-08 21:05:25 +00:00
elif option["value"] is False:
pass
else:
cmd_str += "--" + str(option_dest) + ' "' + str(option["value"]) + '" '
for format in [".bat", ".sh"]:
command = open('build-exe-pyinstaller-command'+format, 'w')
if filename == "":
print("No filename data was found in json file.")
command.write("")
else:
command.write(cmd_str + ' --distpath "output/" --workpath "build/" "' + filename + '"')
command.close()