forked from mcedit/mcedit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
202 lines (171 loc) · 4.46 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
from esky import bdist_esky
from setuptools import setup
import os
import sys
import glob
import subprocess
import platform
LONG_DESC = '''
World / Saved Game Editor for the indie game Minecraft
Import and export creations from saved games. Brush tools allow modifying
terrain on a larger scale. Create, remove, and regenerate chunks in modern
'infinite' Minecraft levels.
Works with saved games from Minecraft Classic, Indev, Infdev, Alpha, Beta,
Release, and Pocket Edition.
'''
if "--stable" in sys.argv:
DEVELOP = False
sys.argv.remove('--stable')
else:
DEVELOP = True
def get_git_version():
"""
Get the version from git.
"""
if DEVELOP:
match = '--match=*.*.*build*'
else:
match = '--match=*.*.*'
try:
version = subprocess.check_output('git describe --abbrev=4 --tags'.split() + [match]).strip()
except:
version = 'unknown'
fout = open('RELEASE-VERSION', 'wb')
fout.write(version)
fout.write('\n')
fout.close()
fout = open('GIT-COMMIT', 'wb')
try:
commit = subprocess.check_output('git rev-parse HEAD'.split()).strip()
except:
commit = 'unknown'
fout.write(commit)
fout.write('\n')
fout.close()
return version
# setup() options that are common on all platforms.
SETUP_COMMON = {
# General fields,
'name': 'MCEdit_dev' if DEVELOP else 'MCEdit',
'version': get_git_version(),
'description': 'Minecraft World Editor',
'long_description': LONG_DESC,
'author': 'David Vierra',
'author_email': 'codewarrior0@gmail.com',
'url': 'http://www.mcedit.net/',
# PyPi,
'keywords': 'minecraft world editor',
'classifiers': [
'Programming Language :: Python',
'Programming Language :: Python :: 2',
],
# Building,
'packages': [
'pymclevel',
],
'package_data': {
'pymclevel': [
'*.yaml',
'*.txt',
'_nbt.*'
],
'filters': [
'filters/**'
],
'stock-schematics': [
'stock-schematics/**'
]
},
'scripts': [
'mcedit.py'
]
}
ESKY_OPTIONS = {
'bdist_esky': {
'includes': [
'ctypes',
'logging',
'OpenGL.arrays.*',
'OpenGL.platform',
'OpenGL.platform.win32',
'encodings'
],
'excludes': [
'Tkconstants',
'Tkinter',
'tcl',
'Cython'
],
'freezer_options': {
# py2exe extras
'optimize': 2,
'compressed': True,
'bundle_files': 3,
'dll_excludes': [
'mswsock.dll',
'powrprof.dll'
],
# py2app extras
'iconfile': 'mcedit.icns',
'plist': {
'CFBundleIdentifier': 'net.mcedit.mcedit'
}
}
}
}
def build_nbt():
"""
Builds _nbt.py.
"""
os.chdir('pymclevel')
os.system(sys.executable + ' setup.py build_ext --inplace --force')
os.chdir('..')
def setup_win32():
"""
Packing setup for Windows 32/64.
"""
import py2exe
# This little ditty makes sure the font module is available
origIsSystemDLL = py2exe.build_exe.isSystemDLL
def isSystemDLL(pathname):
if os.path.basename(pathname).lower() in ['sdl_ttf.dll']:
return 0
return origIsSystemDLL(pathname)
py2exe.build_exe.isSystemDLL = isSystemDLL
def get_data_files(dirs):
"""
Recursively include data directories.
"""
results = []
for directory in dirs:
for root, dirs, files in os.walk(directory):
files = [os.path.join(root, file_) for file_ in files]
results.append((root, files))
return results
def main():
build_nbt()
if platform.system() == 'Windows':
setup_win32()
include_dirs = ['fonts', 'toolicons', 'stock-schematics', 'filters']
data_files = get_data_files(include_dirs) + [
('', [
'README.html',
'favicon.png',
'terrain-classic.png',
'terrain-pocket.png',
'char.png',
'gui.png',
'terrain.png',
'RELEASE-VERSION',
'GIT-COMMIT',
])
]
setup(
data_files=data_files,
options=ESKY_OPTIONS,
**SETUP_COMMON
)
os.unlink('RELEASE-VERSION')
os.unlink('GIT-COMMIT')
if __name__ == '__main__':
main()