2020-10-25 01:23:24 +00:00
|
|
|
import json
|
|
|
|
import os
|
2020-10-31 03:04:14 +00:00
|
|
|
from helpers.os_environment import isWindows
|
2020-10-25 01:23:24 +00:00
|
|
|
|
|
|
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
parent_path = os.path.dirname(dir_path)
|
|
|
|
|
|
|
|
in_file = open('build-exe-config.template.json', 'r')
|
|
|
|
config = json.loads(in_file.read())
|
|
|
|
in_file.close()
|
|
|
|
|
|
|
|
for option in config["pyinstallerOptions"]:
|
2020-10-29 01:41:01 +00:00
|
|
|
if option["optionDest"] in ["datas", "filenames", "icon_file"]:
|
2021-04-26 11:44:22 +00:00
|
|
|
# If we wanted a relative output directory, this will go missing in abspath on windows.
|
|
|
|
relative_fix = False
|
2021-04-26 11:56:49 +00:00
|
|
|
split = option["value"].split(";")
|
|
|
|
if len(split) > 1 and split[1] == "./":
|
2021-04-26 11:44:22 +00:00
|
|
|
relative_fix = True
|
|
|
|
|
2020-10-29 01:41:01 +00:00
|
|
|
option["value"] = os.path.abspath(parent_path + option["value"])
|
2020-10-31 03:04:14 +00:00
|
|
|
if not isWindows():
|
2021-04-08 21:21:28 +00:00
|
|
|
option["value"] = option["value"].replace(";", ":")
|
2021-04-26 11:44:22 +00:00
|
|
|
elif relative_fix:
|
2021-09-11 16:48:57 +00:00
|
|
|
# Add the windows relative path.
|
|
|
|
option["value"] += "./"
|
2020-10-25 01:23:24 +00:00
|
|
|
|
|
|
|
out_file = open('build-exe-config.json', 'w')
|
|
|
|
out_file.write(json.dumps(config, indent=2))
|
|
|
|
out_file.close()
|