-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
116 lines (98 loc) · 3.25 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# -*- coding:Utf-8 -*
import os
import sys
from cx_Freeze import setup, Executable
#############################################################################
# Recupération des valeurs
application = "navy"
app_globals = dict()
with open(os.path.join(application, "version.py")) as file:
exec(file.read(), app_globals)
executable_infos = {
"project_name": "Navy game",
"description": "A python-based sea battle game",
"author": "Francis Clairicia-Rose-Claire-Josephine",
"version": app_globals["__version__"],
"executables": [
{
"script": "run.pyw",
"name": "Navy",
"base": "Win32GUI",
"icon": "resources/img/icon.ico"
}
]
}
options = {
"path": sys.path,
"includes": [
application,
"pygame",
"my_pygame"
],
"excludes": [],
"include_files": [
"resources",
],
"optimize": 0,
"silent": True
}
print("-----------------------------------{ cx_Freeze }-----------------------------------")
print("Project Name: {project_name}".format(**executable_infos))
print("Author: {author}".format(**executable_infos))
print("Version: {version}".format(**executable_infos))
print("Description: {description}".format(**executable_infos))
print()
for i, infos in enumerate(executable_infos["executables"], start=1):
print(f"Executable number {i}")
print("Name: {name}".format(**infos))
print("Icon: {icon}".format(**infos))
print()
print("Modules: {includes}".format(**options))
print("Additional files/folders: {include_files}".format(**options))
print()
while True:
OK = input("Is this ok ? (y/n) : ").lower()
if OK in ("y", "n"):
break
if OK == "n":
sys.exit(0)
print("-----------------------------------------------------------------------------------")
if "tkinter" not in options["includes"]:
options["excludes"].append("tkinter")
# pour inclure sous Windows les dll system de Windows necessaires
if sys.platform == "win32":
options["include_msvcr"] = True
#############################################################################
# preparation de la cible
executables = list()
for infos in executable_infos["executables"]:
target = Executable(
script=os.path.join(sys.path[0], infos["script"]),
base=infos["base"] if sys.platform == "win32" else None,
targetName=infos["name"] + ".exe",
icon=infos.get("icon"),
copyright=executable_infos.get("copyright")
)
executables.append(target)
#############################################################################
# creation du setup
sys.argv = [sys.argv[0], "build"]
try:
result = str()
setup(
name=executable_infos["project_name"],
version=executable_infos["version"],
description=executable_infos["description"],
author=executable_infos["author"],
options={"build_exe": options},
executables=executables
)
except Exception as e:
result = f"{e.__class__.__name__}: {e}"
else:
result = "Build done"
finally:
print("-----------------------------------------------------------------------------------")
print(result)
print("-----------------------------------------------------------------------------------")
os.system("pause")