compile all user starting points

This commit is contained in:
Fabian Dill 2020-02-02 22:36:55 +01:00
parent 6ffaad0afe
commit 8ea3f34898
3 changed files with 37 additions and 11 deletions

View File

@ -85,7 +85,14 @@ if __name__ == "__main__":
player_names = list(file[:-5] for file in player_files)
command = f"py -{py_version} Mystery.py --multi {len(player_files)} {player_string} " \
if os.path.exists("BerserkerMultiServer.exe"):
basemysterycommand = "BerserkerMystery.exe" #compiled windows
elif os.path.exists("BerserkerMultiServer"):
basemysterycommand = "BerserkerMystery" # compiled linux
else:
basemysterycommand = f"py -{py_version} Mystery.py" #source
command = f"{basemysterycommand} --multi {len(player_files)} {player_string} " \
f"--names {','.join(player_names)} --enemizercli {enemizer_location} " \
f"--outputpath {outputpath}" + " --create_spoiler" if create_spoiler else "" + " --race" if race else ""
print(command)
@ -128,7 +135,15 @@ if __name__ == "__main__":
os.remove(file)
print(f"Removed file {file} that is now present in the zipfile")
subprocess.call(f"py -{py_version} MultiServer.py --multidata {os.path.join(outputpath, multidataname)}")
if os.path.exists("BerserkerMultiServer.exe"):
baseservercommand = "BerserkerMultiServer.exe" # compiled windows
elif os.path.exists("BerserkerMultiServer"):
baseservercommand = "BerserkerMultiServer" # compiled linux
else:
baseservercommand = f"py -{py_version} MultiServer.py" # source
#don't have a mac to test that. If you try to run compiled on mac, good luck.
subprocess.call(f"{baseservercommand} --multidata {os.path.join(outputpath, multidataname)}")
except:
import traceback
traceback.print_exc()

View File

@ -36,13 +36,15 @@ def local_path(path):
if local_path.cached_path is not None:
return os.path.join(local_path.cached_path, path)
if is_bundled():
# we are running in a bundle
if is_bundled() and hasattr(sys, "_MEIPASS"):
# we are running in a PyInstaller bundle
local_path.cached_path = sys._MEIPASS # pylint: disable=protected-access,no-member
elif is_bundled():
#probably cxFreeze
local_path.cached_path = os.path.dirname(sys.argv[0])
else:
# we are running in a normal Python environment
local_path.cached_path = os.path.dirname(os.path.abspath(__file__))
return os.path.join(local_path.cached_path, path)
local_path.cached_path = None

View File

@ -43,10 +43,19 @@ def manifest_creation():
json.dump(manifest, open(manifestpath, "wt"), indent=4)
print("Created Manifest")
EXE = cx_Freeze.Executable(
script="MultiClient.py",
targetName="BerserkerMultiClient" if sys.platform == "linux" else "BerserkerMultiClient.exe"
)
scripts = {"MultiClient.py" : "BerserkerMultiClient",
"MultiMystery.py" : "BerserkerMultiMystery",
"MultiServer.py" : "BerserkerMultiServer",
"gui.py" : "BerserkerMultiCreator",
"Mystery.py" : "BerserkerMystery"}
exes = []
for script, scriptname in scripts.items():
exes.append(cx_Freeze.Executable(
script=script,
targetName=scriptname + ("" if sys.platform == "linux" else ".exe"))
)
import datetime
@ -57,7 +66,7 @@ cx_Freeze.setup(
name="HonorarPlus",
version=f"{buildtime.year}.{buildtime.month}.{buildtime.day}.{buildtime.hour}",
description="HonorarPlus",
executables=[EXE],
executables=exes,
options={
"build_exe": {
"zip_include_packages": ["*"],
@ -87,7 +96,7 @@ def installfile(path):
print('Warning,', path, 'not found')
extra_data = ["LICENSE"]
extra_data = ["LICENSE", "data", "EnemizerCLI"]
for data in extra_data:
installfile(Path(data))