Fix formatting
This commit is contained in:
parent
db1cfd12f0
commit
b4d02e3686
137
buildPy2exe.py
137
buildPy2exe.py
@ -2,11 +2,12 @@
|
|||||||
#coding:utf8
|
#coding:utf8
|
||||||
|
|
||||||
|
|
||||||
#*** TROUBLESHOOTING ***
|
# *** TROUBLESHOOTING ***
|
||||||
#1) If you get the error "ImportError: No module named zope.interface" then add an empty __init__.py file to the PYTHONDIR/Lib/site-packages/zope directory
|
# 1) If you get the error "ImportError: No module named zope.interface" then add an empty __init__.py file to the PYTHONDIR/Lib/site-packages/zope directory
|
||||||
#2) It is expected that you will have NSIS 3 NSIS from http://nsis.sourceforge.net installed.
|
# 2) It is expected that you will have NSIS 3 NSIS from http://nsis.sourceforge.net installed.
|
||||||
|
|
||||||
import sys, codecs
|
import codecs
|
||||||
|
import sys
|
||||||
# try:
|
# try:
|
||||||
# if (sys.version_info.major != 2) or (sys.version_info.minor < 7):
|
# if (sys.version_info.major != 2) or (sys.version_info.minor < 7):
|
||||||
# raise Exception("You must build Syncplay with Python 2.7!")
|
# raise Exception("You must build Syncplay with Python 2.7!")
|
||||||
@ -14,23 +15,26 @@ import sys, codecs
|
|||||||
# import warnings
|
# import warnings
|
||||||
# warnings.warn("You must build Syncplay with Python 2.7!")
|
# warnings.warn("You must build Syncplay with Python 2.7!")
|
||||||
|
|
||||||
|
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
from string import Template
|
||||||
|
|
||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
try:
|
try:
|
||||||
from py2exe.build_exe import py2exe
|
from py2exe.build_exe import py2exe
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from py2exe.distutils_buildexe import py2exe
|
from py2exe.distutils_buildexe import py2exe
|
||||||
from string import Template
|
|
||||||
|
|
||||||
import syncplay
|
import syncplay
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
from syncplay.messages import getMissingStrings
|
from syncplay.messages import getMissingStrings
|
||||||
|
|
||||||
missingStrings = getMissingStrings()
|
missingStrings = getMissingStrings()
|
||||||
if missingStrings is not None and missingStrings is not "":
|
if missingStrings is not None and missingStrings is not "":
|
||||||
import warnings
|
import warnings
|
||||||
warnings.warn("MISSING/UNUSED STRINGS DETECTED:\n{}".format(missingStrings))
|
warnings.warn("MISSING/UNUSED STRINGS DETECTED:\n{}".format(missingStrings))
|
||||||
|
|
||||||
|
|
||||||
def get_nsis_path():
|
def get_nsis_path():
|
||||||
bin_name = "makensis.exe"
|
bin_name = "makensis.exe"
|
||||||
from winreg import HKEY_LOCAL_MACHINE as HKLM
|
from winreg import HKEY_LOCAL_MACHINE as HKLM
|
||||||
@ -44,6 +48,8 @@ def get_nsis_path():
|
|||||||
raise Exception("You must install NSIS 3 or later.")
|
raise Exception("You must install NSIS 3 or later.")
|
||||||
except WindowsError:
|
except WindowsError:
|
||||||
return bin_name
|
return bin_name
|
||||||
|
|
||||||
|
|
||||||
NSIS_COMPILE = get_nsis_path()
|
NSIS_COMPILE = get_nsis_path()
|
||||||
|
|
||||||
OUT_DIR = "syncplay_v{}".format(syncplay.version)
|
OUT_DIR = "syncplay_v{}".format(syncplay.version)
|
||||||
@ -246,11 +252,11 @@ NSIS_SCRIPT_TEMPLATE = r"""
|
|||||||
Push English
|
Push English
|
||||||
Push $${LANG_POLISH}
|
Push $${LANG_POLISH}
|
||||||
Push Polski
|
Push Polski
|
||||||
Push $${LANG_RUSSIAN}
|
Push $${LANG_RUSSIAN}
|
||||||
Push Русский
|
Push Русский
|
||||||
Push $${LANG_GERMAN}
|
Push $${LANG_GERMAN}
|
||||||
Push Deutsch
|
Push Deutsch
|
||||||
Push $${LANG_ITALIAN}
|
Push $${LANG_ITALIAN}
|
||||||
Push Italiano
|
Push Italiano
|
||||||
Push A ; A means auto count languages
|
Push A ; A means auto count languages
|
||||||
LangDLL::LangDialog "Language Selection" "Please select the language of Syncplay and the installer"
|
LangDLL::LangDialog "Language Selection" "Please select the language of Syncplay and the installer"
|
||||||
@ -322,25 +328,25 @@ NSIS_SCRIPT_TEMPLATE = r"""
|
|||||||
;$${EndIf}
|
;$${EndIf}
|
||||||
|
|
||||||
$${If} $$CheckBox_VLC_State == $${BST_CHECKED}
|
$${If} $$CheckBox_VLC_State == $${BST_CHECKED}
|
||||||
$${NSD_Check} $$CheckBox_VLC
|
$${NSD_Check} $$CheckBox_VLC
|
||||||
$${EndIf}
|
$${EndIf}
|
||||||
|
|
||||||
Call UpdateVLCCheckbox
|
Call UpdateVLCCheckbox
|
||||||
|
|
||||||
$${If} $$CheckBox_StartMenuShortcut_State == $${BST_CHECKED}
|
$${If} $$CheckBox_StartMenuShortcut_State == $${BST_CHECKED}
|
||||||
$${NSD_Check} $$CheckBox_StartMenuShortcut
|
$${NSD_Check} $$CheckBox_StartMenuShortcut
|
||||||
$${EndIf}
|
$${EndIf}
|
||||||
|
|
||||||
$${If} $$CheckBox_DesktopShortcut_State == $${BST_CHECKED}
|
$${If} $$CheckBox_DesktopShortcut_State == $${BST_CHECKED}
|
||||||
$${NSD_Check} $$CheckBox_DesktopShortcut
|
$${NSD_Check} $$CheckBox_DesktopShortcut
|
||||||
$${EndIf}
|
$${EndIf}
|
||||||
|
|
||||||
$${If} $$CheckBox_QuickLaunchShortcut_State == $${BST_CHECKED}
|
$${If} $$CheckBox_QuickLaunchShortcut_State == $${BST_CHECKED}
|
||||||
$${NSD_Check} $$CheckBox_QuickLaunchShortcut
|
$${NSD_Check} $$CheckBox_QuickLaunchShortcut
|
||||||
$${EndIf}
|
$${EndIf}
|
||||||
|
|
||||||
$${If} $$CheckBox_AutomaticUpdates_State == $${BST_CHECKED}
|
$${If} $$CheckBox_AutomaticUpdates_State == $${BST_CHECKED}
|
||||||
$${NSD_Check} $$CheckBox_AutomaticUpdates
|
$${NSD_Check} $$CheckBox_AutomaticUpdates
|
||||||
$${EndIf}
|
$${EndIf}
|
||||||
|
|
||||||
nsDialogs::Show
|
nsDialogs::Show
|
||||||
@ -613,6 +619,7 @@ NSIS_SCRIPT_TEMPLATE = r"""
|
|||||||
SectionEnd
|
SectionEnd
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class NSISScript(object):
|
class NSISScript(object):
|
||||||
def create(self):
|
def create(self):
|
||||||
fileList, totalSize = self.getBuildDirContents(OUT_DIR)
|
fileList, totalSize = self.getBuildDirContents(OUT_DIR)
|
||||||
@ -622,12 +629,12 @@ class NSISScript(object):
|
|||||||
|
|
||||||
if os.path.isfile(SETUP_SCRIPT_PATH):
|
if os.path.isfile(SETUP_SCRIPT_PATH):
|
||||||
raise RuntimeError("Cannot create setup script, file exists at {}".format(SETUP_SCRIPT_PATH))
|
raise RuntimeError("Cannot create setup script, file exists at {}".format(SETUP_SCRIPT_PATH))
|
||||||
contents = Template(NSIS_SCRIPT_TEMPLATE).substitute(
|
contents = Template(NSIS_SCRIPT_TEMPLATE).substitute(
|
||||||
version = syncplay.version,
|
version=syncplay.version,
|
||||||
uninstallFiles = uninstallFiles,
|
uninstallFiles=uninstallFiles,
|
||||||
installFiles = installFiles,
|
installFiles=installFiles,
|
||||||
totalSize = totalSize,
|
totalSize=totalSize,
|
||||||
)
|
)
|
||||||
with codecs.open(SETUP_SCRIPT_PATH, "w", "utf-8-sig") as outfile:
|
with codecs.open(SETUP_SCRIPT_PATH, "w", "utf-8-sig") as outfile:
|
||||||
outfile.write(contents)
|
outfile.write(contents)
|
||||||
|
|
||||||
@ -669,6 +676,7 @@ class NSISScript(object):
|
|||||||
delete.append('RMdir "$INSTDIR\\{}"'.format(file_))
|
delete.append('RMdir "$INSTDIR\\{}"'.format(file_))
|
||||||
return "\n".join(delete)
|
return "\n".join(delete)
|
||||||
|
|
||||||
|
|
||||||
class build_installer(py2exe):
|
class build_installer(py2exe):
|
||||||
def run(self):
|
def run(self):
|
||||||
py2exe.run(self)
|
py2exe.run(self)
|
||||||
@ -678,29 +686,37 @@ class build_installer(py2exe):
|
|||||||
script.compile()
|
script.compile()
|
||||||
print("*** DONE ***")
|
print("*** DONE ***")
|
||||||
|
|
||||||
guiIcons = ['resources/accept.png', 'resources/arrow_undo.png', 'resources/clock_go.png',
|
|
||||||
'resources/control_pause_blue.png', 'resources/cross.png', 'resources/door_in.png',
|
guiIcons = [
|
||||||
'resources/folder_explore.png', 'resources/help.png', 'resources/table_refresh.png',
|
'resources/accept.png', 'resources/arrow_undo.png', 'resources/clock_go.png',
|
||||||
'resources/timeline_marker.png','resources/control_play_blue.png',
|
'resources/control_pause_blue.png', 'resources/cross.png', 'resources/door_in.png',
|
||||||
'resources/mpc-hc.png','resources/mpc-hc64.png','resources/mplayer.png',
|
'resources/folder_explore.png', 'resources/help.png', 'resources/table_refresh.png',
|
||||||
'resources/mpc-be.png',
|
'resources/timeline_marker.png', 'resources/control_play_blue.png',
|
||||||
'resources/mpv.png','resources/vlc.png', 'resources/house.png', 'resources/film_link.png',
|
'resources/mpc-hc.png', 'resources/mpc-hc64.png', 'resources/mplayer.png',
|
||||||
'resources/eye.png', 'resources/comments.png', 'resources/cog_delete.png', 'resources/chevrons_right.png',
|
'resources/mpc-be.png',
|
||||||
'resources/user_key.png', 'resources/lock.png', 'resources/key_go.png', 'resources/page_white_key.png',
|
'resources/mpv.png', 'resources/vlc.png', 'resources/house.png', 'resources/film_link.png',
|
||||||
'resources/tick.png', 'resources/lock_open.png', 'resources/empty_checkbox.png', 'resources/tick_checkbox.png',
|
'resources/eye.png', 'resources/comments.png', 'resources/cog_delete.png', 'resources/chevrons_right.png',
|
||||||
'resources/world_explore.png', 'resources/application_get.png', 'resources/cog.png', 'resources/arrow_switch.png',
|
'resources/user_key.png', 'resources/lock.png', 'resources/key_go.png', 'resources/page_white_key.png',
|
||||||
'resources/film_go.png', 'resources/world_go.png', 'resources/arrow_refresh.png', 'resources/bullet_right_grey.png',
|
'resources/tick.png', 'resources/lock_open.png', 'resources/empty_checkbox.png', 'resources/tick_checkbox.png',
|
||||||
'resources/user_comment.png',
|
'resources/world_explore.png', 'resources/application_get.png', 'resources/cog.png', 'resources/arrow_switch.png',
|
||||||
'resources/error.png',
|
'resources/film_go.png', 'resources/world_go.png', 'resources/arrow_refresh.png', 'resources/bullet_right_grey.png',
|
||||||
'resources/film_folder_edit.png',
|
'resources/user_comment.png',
|
||||||
'resources/film_edit.png',
|
'resources/error.png',
|
||||||
'resources/folder_film.png',
|
'resources/film_folder_edit.png',
|
||||||
'resources/shield_edit.png',
|
'resources/film_edit.png',
|
||||||
'resources/shield_add.png',
|
'resources/folder_film.png',
|
||||||
'resources/email_go.png',
|
'resources/shield_edit.png',
|
||||||
'resources/world_add.png', 'resources/film_add.png', 'resources/delete.png', 'resources/spinner.mng'
|
'resources/shield_add.png',
|
||||||
]
|
'resources/email_go.png',
|
||||||
resources = ["resources/icon.ico", "resources/syncplay.png", "resources/syncplayintf.lua", "resources/license.rtf", "resources/third-party-notices.rtf"]
|
'resources/world_add.png', 'resources/film_add.png', 'resources/delete.png', 'resources/spinner.mng'
|
||||||
|
]
|
||||||
|
resources = [
|
||||||
|
"resources/icon.ico",
|
||||||
|
"resources/syncplay.png",
|
||||||
|
"resources/syncplayintf.lua",
|
||||||
|
"resources/license.rtf",
|
||||||
|
"resources/third-party-notices.rtf"
|
||||||
|
]
|
||||||
resources.extend(guiIcons)
|
resources.extend(guiIcons)
|
||||||
intf_resources = ["resources/lua/intf/syncplay.lua"]
|
intf_resources = ["resources/lua/intf/syncplay.lua"]
|
||||||
|
|
||||||
@ -714,23 +730,28 @@ common_info = dict(
|
|||||||
|
|
||||||
info = dict(
|
info = dict(
|
||||||
common_info,
|
common_info,
|
||||||
windows=[{"script":"syncplayClient.py", "icon_resources":[(1, "resources\\icon.ico")], 'dest_base': "Syncplay"},],
|
windows=[{
|
||||||
|
"script": "syncplayClient.py",
|
||||||
|
"icon_resources": [(1, "resources\\icon.ico")],
|
||||||
|
'dest_base': "Syncplay"},
|
||||||
|
],
|
||||||
console=['syncplayServer.py'],
|
console=['syncplayServer.py'],
|
||||||
# *** If you wish to make the Syncplay client use console mode (for --no-gui to work) then comment out the above two lines and uncomment the following line:
|
# *** If you wish to make the Syncplay client use console mode (for --no-gui to work) then comment out the above two lines and uncomment the following line:
|
||||||
# console=['syncplayServer.py', {"script":"syncplayClient.py", "icon_resources":[(1, "resources\\icon.ico")], 'dest_base': "Syncplay"}],
|
# console=['syncplayServer.py', {"script":"syncplayClient.py", "icon_resources":[(1, "resources\\icon.ico")], 'dest_base': "Syncplay"}],
|
||||||
options={'py2exe': {
|
options={
|
||||||
'dist_dir': OUT_DIR,
|
'py2exe': {
|
||||||
'packages': 'PySide.QtUiTools',
|
'dist_dir': OUT_DIR,
|
||||||
'includes': 'twisted, sys, encodings, datetime, os, time, math, PySide, liburl, ast, unicodedata, _ssl',
|
'packages': 'PySide.QtUiTools',
|
||||||
'excludes': 'venv, doctest, pdb, unittest, win32clipboard, win32file, win32pdh, win32security, win32trace, win32ui, winxpgui, win32pipe, win32process, Tkinter',
|
'includes': 'twisted, sys, encodings, datetime, os, time, math, PySide, liburl, ast, unicodedata, _ssl',
|
||||||
'dll_excludes': 'msvcr71.dll, MSVCP90.dll, POWRPROF.dll',
|
'excludes': 'venv, doctest, pdb, unittest, win32clipboard, win32file, win32pdh, win32security, win32trace, win32ui, winxpgui, win32pipe, win32process, Tkinter',
|
||||||
'optimize': 2,
|
'dll_excludes': 'msvcr71.dll, MSVCP90.dll, POWRPROF.dll',
|
||||||
'compressed': 1
|
'optimize': 2,
|
||||||
}
|
'compressed': 1
|
||||||
},
|
}
|
||||||
data_files = [("resources", resources),("resources/lua/intf", intf_resources)],
|
},
|
||||||
zipfile = "lib/libsync",
|
data_files=[("resources", resources), ("resources/lua/intf", intf_resources)],
|
||||||
cmdclass = {"py2exe": build_installer},
|
zipfile="lib/libsync",
|
||||||
|
cmdclass={"py2exe": build_installer},
|
||||||
)
|
)
|
||||||
|
|
||||||
sys.argv.extend(['py2exe', '-p win32com ', '-i twisted.web.resource', '-i PySide.QtCore', '-i PySide.QtGui'])
|
sys.argv.extend(['py2exe', '-p win32com ', '-i twisted.web.resource', '-i PySide.QtCore', '-i PySide.QtGui'])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user