This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
95 lines (74 loc) · 2.19 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
#!/usr/bin/env python
import subprocess,re,os,sys
from cx_Freeze import setup, Executable
try:
label = subprocess.check_output(["git", "describe", "--always", "--tags"])
except WindowsError:
raise Exception("Install git")
splited = label.strip('\n').split('-')
print splited
if len(splited)==1:
tags = splited[0]
hotfix = "0"
elif len(splited)>1:
tags = splited[0]
hotfix = splited[1]
else:
print splited
raise Exception("Unknown")
if tags[0:1] == "v":
tags = tags[1:]
__version__ = tags + "." + hotfix
__version_long__ = tags + " hotfix " + hotfix
#describe don't give the right thing (add a g)
git_hash =subprocess.check_output(["git", "rev-parse", "master"]).strip("\n") #should use HEAD instead of maste
git_hash_short = git_hash[:7]
with open("_version.py","w") as f:
fw=f.write
fw("""__version__ = "%s.%s"\n"""%(tags, hotfix))
fw("""__version_long__ = "%s hotfix %s"\n"""%(tags ,hotfix))
fw("""git_hash= "%s" \n"""%(git_hash))
fw("""git_hash_short= "%s" \n"""%(git_hash_short))
base = None
if sys.platform == "win32":
#base = "Win32GUI"
base = "Console"
executables = [
Executable("reporter.py",
base=base,
icon="image/icon.ico"
),
Executable("BeamNG_Tools.py",
base=base,
icon="image/icon.ico"
),
Executable("windows_integration.py",
base=base,
)
]
include_files=[]
include_files.append("LICENSE")
include_files.append("readme.md")
#this loop get all files in the directory array to be coped to tha build directory
for toCopy in ["image","theme"]:
for root, dirs, files in os.walk( toCopy , topdown=True):
for name in files:
fpath = os.path.join(root, name)
include_files.append( (fpath,fpath) )
buildOptions = dict(
optimize = 2,
includes=[],
packages=[],
include_files=include_files,
excludes= [],
zip_includes=[],
include_msvcr = True,
silent = True
)
setup(
name = "BeamNG tools",
version = "0.1.0",
description = " Tools to help BeamNG.Drive modders http://50thomatoes50.github.io/BNG_tools/",
options=dict(build_exe=buildOptions),
executables = executables
)