2014-09-19 14:43:21 +00:00
|
|
|
import glob
|
|
|
|
import os
|
2010-10-29 09:11:40 +00:00
|
|
|
import shutil
|
2014-09-19 14:43:21 +00:00
|
|
|
import sys
|
|
|
|
|
2013-09-08 08:13:36 +00:00
|
|
|
import bbfreeze.recipes
|
2015-07-15 22:09:49 +00:00
|
|
|
import gtk
|
2014-09-19 14:43:21 +00:00
|
|
|
import icon
|
|
|
|
from bbfreeze import Freezer
|
2012-11-22 23:22:34 +00:00
|
|
|
|
2015-07-15 22:09:49 +00:00
|
|
|
import deluge.common
|
|
|
|
|
2012-11-22 23:22:34 +00:00
|
|
|
# Get build_version from installed deluge
|
|
|
|
build_version = deluge.common.get_version()
|
|
|
|
print "Deluge Version: %s" % build_version
|
2013-07-10 03:46:38 +00:00
|
|
|
python_path = os.path.dirname(sys.executable)
|
|
|
|
if python_path.endswith("Scripts"):
|
|
|
|
python_path = python_path[:-8]
|
|
|
|
python_path += os.path.sep
|
2012-11-22 23:22:34 +00:00
|
|
|
|
2013-07-10 03:46:38 +00:00
|
|
|
print "Python Path: %s" % python_path
|
|
|
|
gtk_root = os.path.join(gtk.__path__[0], "..\\runtime\\")
|
2010-10-29 09:11:40 +00:00
|
|
|
|
2012-11-22 23:22:34 +00:00
|
|
|
# Include python modules not picked up automatically by bbfreeze
|
2014-09-19 18:10:09 +00:00
|
|
|
includes = ("libtorrent", "cairo", "pangocairo", "atk", "pango", "twisted.internet.utils",
|
|
|
|
"gio", "gzip", "email.mime.multipart", "email.mime.text")
|
|
|
|
excludes = ("numpy", "OpenGL", "psyco", "win32ui")
|
2012-04-18 12:15:52 +00:00
|
|
|
|
|
|
|
dst = "..\\build-win32\\deluge-bbfreeze-" + build_version + "\\"
|
2010-10-29 09:11:40 +00:00
|
|
|
|
2014-09-19 18:10:09 +00:00
|
|
|
|
2012-11-22 23:22:34 +00:00
|
|
|
# Need to override bbfreeze function so that it includes all gtk libraries
|
|
|
|
# in the installer so users don't require a separate GTK+ installation.
|
|
|
|
def recipe_gtk_override(mf):
|
|
|
|
return True
|
|
|
|
bbfreeze.recipes.recipe_gtk_and_friends = recipe_gtk_override
|
|
|
|
|
2012-04-18 12:15:52 +00:00
|
|
|
f = Freezer(dst, includes=includes, excludes=excludes)
|
|
|
|
f.include_py = False
|
2013-09-08 08:13:36 +00:00
|
|
|
# Can/should we grab this from setup.py entry_points somehow
|
|
|
|
gui_scripts = ["deluge", "deluged", "deluge-web", "deluge-gtk"]
|
|
|
|
console_scripts = ["deluge-debug", "deluged-debug", "deluge-web-debug", "deluge-console"]
|
|
|
|
|
|
|
|
# Copy the scripts to get rid of the '-script' suffix before adding to freezer
|
|
|
|
for script in gui_scripts:
|
|
|
|
shutil.copy(python_path + "Scripts/%s-script.pyw" % script, python_path + "Scripts/%s.pyw" % script)
|
|
|
|
f.addScript(python_path + "Scripts/%s.pyw" % script, gui_only=True)
|
|
|
|
for script in console_scripts:
|
|
|
|
shutil.copy(python_path + "Scripts/%s-script.py" % script, python_path + "Scripts/%s.py" % script)
|
|
|
|
f.addScript(python_path + "Scripts/%s.py" % script, gui_only=False)
|
2010-03-26 20:14:51 +00:00
|
|
|
f() # starts the freezing process
|
2010-10-29 09:11:40 +00:00
|
|
|
|
2013-09-08 08:13:36 +00:00
|
|
|
# Clean up the duplicated scripts
|
|
|
|
for script in gui_scripts:
|
|
|
|
os.remove(python_path + "Scripts/%s.pyw" % script)
|
|
|
|
for script in console_scripts:
|
|
|
|
os.remove(python_path + "Scripts/%s.py" % script)
|
|
|
|
|
2010-10-29 09:11:40 +00:00
|
|
|
# add icons to the exe files
|
|
|
|
icon_path = os.path.join(os.path.dirname(__file__), "deluge.ico")
|
2013-09-08 08:13:36 +00:00
|
|
|
for script in console_scripts + gui_scripts:
|
|
|
|
icon.CopyIcons(dst + script + ".exe", icon_path)
|
2010-10-29 09:11:40 +00:00
|
|
|
|
|
|
|
# exclude files which are already included in GTK or Windows
|
2012-11-22 23:22:34 +00:00
|
|
|
excludeDlls = ("MSIMG32.dll", "MSVCR90.dll", "MSVCP90.dll", "POWRPROF.dll", "DNSAPI.dll", "USP10.dll")
|
|
|
|
for file in excludeDlls:
|
2010-10-29 09:11:40 +00:00
|
|
|
for filename in glob.glob(dst + file):
|
|
|
|
print "removing file:", filename
|
|
|
|
os.remove(filename)
|
2012-11-22 23:22:34 +00:00
|
|
|
|
|
|
|
# copy gtk locale files
|
|
|
|
gtk_locale = os.path.join(gtk_root, 'share/locale')
|
|
|
|
locale_include_list = ['gtk20.mo', 'locale.alias']
|
2014-09-19 18:10:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
def ignored_files(adir, filenames):
|
2012-11-22 23:22:34 +00:00
|
|
|
return [
|
|
|
|
filename for filename in filenames
|
|
|
|
if not os.path.isdir(os.path.join(adir, filename))
|
|
|
|
and filename not in locale_include_list
|
2014-09-19 18:10:09 +00:00
|
|
|
]
|
2012-11-22 23:22:34 +00:00
|
|
|
shutil.copytree(gtk_locale, os.path.join(dst, 'share/locale'), ignore=ignored_files)
|
|
|
|
|
|
|
|
# copy gtk theme files
|
|
|
|
theme_include_list = [
|
2013-02-22 16:34:34 +00:00
|
|
|
[gtk_root, "share/icons/hicolor/index.theme"],
|
|
|
|
[gtk_root, "lib/gtk-2.0/2.10.0/engines"],
|
|
|
|
[gtk_root, "share/themes/MS-Windows"],
|
|
|
|
["DelugeStart Theme", "lib/gtk-2.0/2.10.0/engines/libmurrine.dll"],
|
|
|
|
["DelugeStart Theme", "share/themes/DelugeStart"],
|
|
|
|
["DelugeStart Theme", "etc/gtk-2.0/gtkrc"]
|
2014-09-19 18:10:09 +00:00
|
|
|
]
|
2013-02-22 16:34:34 +00:00
|
|
|
for path_root, path in theme_include_list:
|
|
|
|
full_path = os.path.join(path_root, path)
|
2012-11-22 23:22:34 +00:00
|
|
|
if os.path.isdir(full_path):
|
|
|
|
shutil.copytree(full_path, os.path.join(dst, path))
|
|
|
|
else:
|
|
|
|
dst_dir = os.path.join(dst, os.path.dirname(path))
|
|
|
|
try:
|
|
|
|
os.makedirs(dst_dir)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
shutil.copy(full_path, dst_dir)
|
|
|
|
|
|
|
|
file = open('VERSION.tmp', 'w')
|
|
|
|
file.write("build_version = \"%s\"" % build_version)
|
|
|
|
file.close()
|