1
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3
# !!! THIS SCRIPT WILL DELETE THE BIN FOLDER !!!
5
# !!! and all its contents and then it will !!!
6
# !!! create a new one from scratch. !!!
7
# !!! You have been warned. !!!
9
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
11
# this is RUN ON WINDOWS and
12
# needs some tools installed:
15
# wxpython 2.8 (the unicode version)
16
# upx.exe (must be in the PATH)
17
# pythonwin extensions (needed by pyinstaller)
18
# pyinstaller latest trunk (in c:\pyinst\)
20
# also put a copy of tor.exe into src/Tor
22
# run make_windows_binary.py from within the src directory and
23
# you should end up with the zip files in the ../release folder
24
# and a fresh bin folder to test the newly created torchat.exe
34
# pyinstaller must have been configured aleady
35
PYINSTALLER_PATH = "c:\\pyinst"
38
# ----------------------------------------------------
39
# first some useful helpers to zip, copy, delete files
40
# ----------------------------------------------------
42
class MyZip(zipfile.ZipFile):
43
def add(self, pattern):
44
for name in glob.glob(pattern):
45
print "adding %s" % name
46
self.write(name, name, zipfile.ZIP_DEFLATED)
49
"""delete files. takes a list of names or patterns"""
50
for pattern in patterns:
51
print "trying to unlink %s" % pattern
52
for name in glob.glob(pattern):
55
print "unlinked %s" % name
57
print "could not unlink %s" % name
60
"""copy files. takes a list of tuples of which
61
the first element is a name or pattern and the
62
second one is is the destination directory"""
63
for pattern, dest_dir in patterns:
64
print "trying to copy %s to %s" % (pattern, dest_dir)
65
for name in glob.glob(pattern):
67
shutil.copy(name, dest_dir)
68
print "copied %s" % name
70
print "could not copy %s" % name
72
def zip(zipfile_name, patterns):
73
"""add files to the archive zipfile_name.
74
Takes a list of filenames or wildcard patterns"""
75
print "\nopening %s" % zipfile_name
76
archive = MyZip(zipfile_name, "a")
77
zlib.Z_DEFAULT_COMPRESSION = zlib.Z_BEST_COMPRESSION
78
for pattern in patterns:
80
print "closing %s" % zipfile_name
83
def zipSrc(zipfile_name):
93
"src\\translations\\*.txt",
94
"src\\translations\\lang_*.py",
95
"src\\translations\\insert_missing.py",
96
"src\\translations\\__init__.py",
98
"src\\SocksiPy\\*.py",
99
"src\\SocksiPy\\BUGS",
100
"src\\SocksiPy\\LICENSE",
101
"src\\SocksiPy\\README",
107
"src\\Tor\\torrc.txt"
110
def zipBin(zipfile_name):
118
print "\ncleaning %s" % folder
120
"%s\\*.pyo" % folder,
121
"%s\\*.pyc" % folder,
122
"%s\\*.log" % folder,
123
"%s\\*.tmp" % folder,
125
"%s\\*offline*" % folder,
126
"%s\\*incoming*" % folder,
127
"%s\\DEADJOE" % folder
132
clean("translations")
140
os.mkdir("..\\release")
144
if not os.path.exists("Tor\\tor.exe"):
145
print "!!! need a copy of tor.exe in the src\\Tor folder"
148
# clean up the src directory
150
os.system("rmdir /S /Q dist")
151
os.system("rmdir /S /Q build")
153
# build the .exe with pyinstaller
154
# the following will result in a command line like this::
155
# "c:\Python27\python.exe c:\pyinst\Build.py torchat_windows.spec"
156
cmd = sys.executable \
157
+ " " + os.path.join(PYINSTALLER_PATH, 'Build.py') \
158
+ " torchat_windows.spec"
164
if not os.path.exists("dist\\torchat.exe"):
165
print "!!! pyinstaller did not run properly"
168
# now we have all files we need. We now put together
169
# the contents of the bin folder exactly as it will be
170
# in the final zip file. First make an empty bin folder.
171
print "\n\nputting together the contents of the bin folder"
172
os.system("rmdir /S /Q ..\\bin")
173
os.system("mkdir ..\\bin")
174
os.system("mkdir ..\\bin\\icons")
175
os.system("mkdir ..\\bin\\Tor")
177
#now copy the needed files to bin
179
("dist\\torchat.exe", "..\\bin"),
180
("portable.txt", "..\\bin"),
181
("Tor\\tor.exe", "..\\bin\\Tor"),
182
("Tor\\torrc.txt", "..\\bin\\Tor"),
183
("icons\\*.png", "..\\bin\\icons"),
184
("icons\\*.ico", "..\\bin\\icons"),
187
print "\n\ncreating the zip files"
189
bin_zip_filename = "release\\torchat-windows-%s.zip" % version.VERSION
190
src_zip_filename = "release\\torchat-source-%s.zip" % version.VERSION
191
unlink([bin_zip_filename, src_zip_filename])
193
# torchat-windows-x.x.x.x.zip
194
zipBin(bin_zip_filename)
195
zipSrc(bin_zip_filename)
197
# torchat-source-x.x.x.x.zip
198
zipSrc(src_zip_filename)