forked from soundmud/soundrts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
65 lines (58 loc) · 1.95 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
#! .venv\Scripts\python.exe
"""
From the command-line, type: py setup.py build
Or activate the virtual environment and type: python setup.py build
Warning: the py launcher ignores the virtual environment if a "#!" line is specified!
(see PEP 486)
"""
import os
import platform
import shutil
import sys
from subprocess import Popen, check_output
from cx_Freeze import Executable, setup
import builddoc
import buildmultimapslist
from soundrts.version import VERSION
if platform.system() == "Windows" and ".venv" not in sys.executable:
print(f"WARNING: {sys.executable} (not a virtual environment?)")
input("[press Enter to continue; press Control+C to stop]")
try:
full_version = check_output(["git", "describe", "--tags"]).strip().decode()
except FileNotFoundError:
print("WARNING: couldn't get version from git.")
full_version = f"{VERSION}-unknown"
TMP = os.environ["TMP"]
destination = rf"{TMP}\soundrts-{VERSION}-windows"
build_exe_options = {
"build_exe": destination,
"optimize": 1,
"silent": True,
"packages": [],
"excludes": ["Cython", "scipy", "numpy", "tkinter"],
"include_files": ["res", "single", "multi", "mods", "cfg", "doc"],
"replace_paths": [("*", f"{full_version}:")],
}
executables = [
Executable("soundrts.py", base="Win32GUI"),
Executable("server.py", base=None),
]
buildmultimapslist.build()
builddoc.build()
if os.path.exists(destination):
print(f"{destination} already exists. Deleting...")
shutil.rmtree(destination)
setup(
options={"build_exe": build_exe_options},
executables=executables,
name="SoundRTS",
version=VERSION.replace("-dev", ".9999"),
)
print("Creating empty user folder...")
os.mkdir(rf"{destination}\user")
print(r"Resetting cfg\language.txt ...")
open(rf"{destination}\cfg\language.txt", "w").write("")
Popen(rf'explorer /select,"{destination}"')
print("Adding full_version.txt ...")
with open(rf"{destination}\lib\full_version.txt", "w") as t:
t.write(full_version)