2018-07-20 17:21:52 +00:00
#!/usr/bin/env python3
2012-10-12 16:37:12 +00:00
#coding:utf8
2015-01-26 00:47:11 +00:00
2018-07-23 21:08:44 +00:00
# *** 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
# 2) It is expected that you will have NSIS 3 NSIS from http://nsis.sourceforge.net installed.
2015-01-26 00:47:11 +00:00
2018-07-23 21:08:44 +00:00
import codecs
import sys
2018-04-24 14:12:59 +00:00
# try:
# if (sys.version_info.major != 2) or (sys.version_info.minor < 7):
# raise Exception("You must build Syncplay with Python 2.7!")
# except AttributeError:
# import warnings
# warnings.warn("You must build Syncplay with Python 2.7!")
2014-08-03 20:06:40 +00:00
2019-05-06 21:08:35 +00:00
from glob import glob
2018-07-23 21:08:44 +00:00
import os
import subprocess
from string import Template
2012-12-30 13:07:07 +00:00
from distutils . core import setup
2018-04-24 14:30:03 +00:00
try :
from py2exe . build_exe import py2exe
except ImportError :
2018-06-18 15:02:03 +00:00
from py2exe . distutils_buildexe import py2exe
2012-10-12 16:37:12 +00:00
import syncplay
2022-09-24 19:52:50 +00:00
from syncplay . messages import getMissingStrings , getMessage , getLanguages
2018-07-23 21:08:44 +00:00
2014-11-30 17:58:03 +00:00
missingStrings = getMissingStrings ( )
2019-12-30 12:56:27 +00:00
if missingStrings is not None and missingStrings != " " :
2014-11-30 17:58:03 +00:00
import warnings
warnings . warn ( " MISSING/UNUSED STRINGS DETECTED: \n {} " . format ( missingStrings ) )
2017-07-02 13:02:32 +00:00
def get_nsis_path ( ) :
bin_name = " makensis.exe "
2018-04-23 22:44:19 +00:00
from winreg import HKEY_LOCAL_MACHINE as HKLM
from winreg import KEY_READ , KEY_WOW64_32KEY , OpenKey , QueryValueEx
2017-07-02 13:02:32 +00:00
try :
nsisreg = OpenKey ( HKLM , " Software \\ NSIS " , 0 , KEY_READ | KEY_WOW64_32KEY )
if QueryValueEx ( nsisreg , " VersionMajor " ) [ 0 ] > = 3 :
return " {} \\ {} " . format ( QueryValueEx ( nsisreg , " " ) [ 0 ] , bin_name )
else :
raise Exception ( " You must install NSIS 3 or later. " )
except WindowsError :
return bin_name
2018-07-23 21:08:44 +00:00
2017-07-02 13:02:32 +00:00
NSIS_COMPILE = get_nsis_path ( )
2017-10-07 20:02:59 +00:00
OUT_DIR = " syncplay_v {} " . format ( syncplay . version )
2013-01-15 18:27:21 +00:00
SETUP_SCRIPT_PATH = " syncplay_setup.nsi "
2022-09-24 19:52:50 +00:00
languages = getLanguages ( )
def getLangTagFromNLF ( lang ) :
return " LANG_ " + getMessage ( " installer-language-file " , lang ) . upper ( ) . replace ( " .NLF " , " " ) . replace ( " _ " , " " )
# Load languages
loadLanguageFileString = " "
for lang in languages :
lineToAdd = " LoadLanguageFile \" $$ {{ NSISDIR}} \\ Contrib \\ Language files \\ {} \" " . format ( getMessage ( " installer-language-file " , lang ) )
loadLanguageFileString = loadLanguageFileString + " \r \n " + lineToAdd
# Add Version Keys
versionKeysString = " "
for lang in languages :
languageIdent = getLangTagFromNLF ( lang )
lineToAdd = r """ VIAddVersionKey /LANG=$$ {LANG_IDENT} " ProductName " " Syncplay "
VIAddVersionKey / LANG = $ $ { LANG_IDENT } " FileVersion " " $version.0 "
VIAddVersionKey / LANG = $ $ { LANG_IDENT } " LegalCopyright " " Syncplay "
VIAddVersionKey / LANG = $ $ { LANG_IDENT } " FileDescription " " Syncplay "
""" .replace( " LANG_IDENT " , languageIdent)
versionKeysString = versionKeysString + " \r \n " + lineToAdd
# Add Language Strings
languageString = " "
for lang in languages :
languageIdent = getLangTagFromNLF ( lang )
# dict_dict = {'dict1':dict1, 'dicta':dicta, 'dict666':dict666}
#
# for name,dict_ in dict_dict.items():
# print 'the name of the dictionary is ', name
# print 'the dictionary looks like ', dict_
langStringDict = {
# "[NSIS key name]": "[messages_*.py key name]"
" SyncplayLanguage " : " LANGUAGE-TAG " ,
" Associate " : " installer-associate " ,
" Shortcut " : " installer-shortcut " ,
" StartMenu " : " installer-start-menu " ,
" Desktop " : " installer-desktop " ,
" QuickLaunchBar " : " installer-quick-launch-bar " ,
" AutomaticUpdates " : " installer-automatic-updates " ,
" UninstConfig " : " installer-uninstall-configuration "
}
for nsisKey , messageKey in langStringDict . items ( ) :
nsisValue = getMessage ( messageKey , lang )
lineToAdd = " LangString ^ " + nsisKey + " $$ { " + languageIdent + " } \" " + nsisValue + " \" "
languageString = languageString + " \r \n " + lineToAdd
languageString = languageString + " \r \n "
2023-03-14 20:45:38 +00:00
# Add Language Pushs
languagePushString = " "
for lang in languages :
languageIdent = getLangTagFromNLF ( lang )
languagePushString = languagePushString + " Push $$ { " + languageIdent + " } \r \n "
languagePushString = languagePushString + " Push ' " + getMessage ( " LANGUAGE " , lang ) + " ' \r \n "
2013-01-15 18:27:21 +00:00
NSIS_SCRIPT_TEMPLATE = r """
! include LogicLib . nsh
! include nsDialogs . nsh
2013-01-26 21:10:28 +00:00
! include FileFunc . nsh
2013-01-16 14:00:57 +00:00
2022-09-24 19:52:50 +00:00
""" + loadLanguageFileString + r """
2021-12-21 15:39:57 +00:00
2016-12-03 20:52:02 +00:00
Unicode true
2013-01-26 20:37:51 +00:00
Name " Syncplay $version "
2017-12-25 20:46:44 +00:00
OutFile " Syncplay-$version-Setup.exe "
2013-01-15 18:27:21 +00:00
InstallDir $ $ PROGRAMFILES \Syncplay
RequestExecutionLevel admin
2019-03-10 23:09:06 +00:00
ManifestDPIAware false
2013-01-15 18:27:21 +00:00
XPStyle on
2019-04-13 13:39:55 +00:00
Icon syncplay \resources \icon . ico ; Change DIR
2013-01-15 18:27:21 +00:00
SetCompressor / SOLID lzma
2014-11-29 13:56:26 +00:00
2013-01-16 14:00:57 +00:00
VIProductVersion " $version.0 "
2022-02-12 13:44:31 +00:00
2022-09-24 19:52:50 +00:00
""" + versionKeysString + languageString + r """
2014-11-29 15:01:45 +00:00
; Remove text to save space
LangString ^ ClickInstall $ $ { LANG_GERMAN } " "
2013-01-15 18:27:21 +00:00
PageEx license
2019-04-13 13:39:55 +00:00
LicenseData syncplay \resources \license . rtf
2013-01-15 18:27:21 +00:00
PageExEnd
2013-01-29 12:30:40 +00:00
Page custom DirectoryCustom DirectoryCustomLeave
2013-01-15 18:27:21 +00:00
Page instFiles
2014-11-29 13:56:26 +00:00
2013-01-29 14:15:40 +00:00
UninstPage custom un . installConfirm un . installConfirmLeave
2013-01-15 18:27:21 +00:00
UninstPage instFiles
2014-11-29 13:56:26 +00:00
2013-01-29 12:30:40 +00:00
Var Dialog
2013-01-29 14:15:40 +00:00
Var Icon_Syncplay
Var Icon_Syncplay_Handle
2016-07-02 20:00:53 +00:00
; Var CheckBox_Associate
2015-01-03 13:58:18 +00:00
Var CheckBox_AutomaticUpdates
2013-01-29 12:30:40 +00:00
Var CheckBox_StartMenuShortcut
Var CheckBox_DesktopShortcut
Var CheckBox_QuickLaunchShortcut
2016-07-02 20:00:53 +00:00
; Var CheckBox_Associate_State
2015-01-03 13:58:18 +00:00
Var CheckBox_AutomaticUpdates_State
2013-01-29 12:30:40 +00:00
Var CheckBox_StartMenuShortcut_State
Var CheckBox_DesktopShortcut_State
Var CheckBox_QuickLaunchShortcut_State
Var Button_Browse
Var Directory
Var GroupBox_DirSub
Var Label_Text
Var Label_Shortcut
Var Label_Size
Var Label_Space
Var Text_Directory
2014-11-29 13:56:26 +00:00
2013-01-29 14:15:40 +00:00
Var Uninst_Dialog
Var Uninst_Icon
Var Uninst_Icon_Handle
Var Uninst_Label_Directory
Var Uninst_Label_Text
Var Uninst_Text_Directory
Var Uninst_CheckBox_Config
Var Uninst_CheckBox_Config_State
2014-11-29 13:56:26 +00:00
2013-01-29 12:30:40 +00:00
Var Size
Var SizeHex
Var AvailibleSpace
Var AvailibleSpaceGiB
Var Drive
Var VLC_Directory
2014-11-29 13:56:26 +00:00
2016-07-02 20:00:53 +00:00
; ! macro APP_ASSOCIATE EXT FileCLASS DESCRIPTION COMMANDTEXT COMMAND
; WriteRegStr HKCR " .$$ {EXT} " " " " $$ {FileCLASS} "
; WriteRegStr HKCR " $$ {FileCLASS} " " " ` $ $ { DESCRIPTION } `
; WriteRegStr HKCR " $$ {FileCLASS} \ shell " " " " open "
; WriteRegStr HKCR " $$ {FileCLASS} \ shell \ open " " " ` $ $ { COMMANDTEXT } `
; WriteRegStr HKCR " $$ {FileCLASS} \ shell \ open \ command " " " ` $ $ { COMMAND } `
; ! macroend
2014-11-29 13:56:26 +00:00
2013-01-15 18:27:21 +00:00
! macro APP_UNASSOCIATE EXT FileCLASS
; Backup the previously associated File class
ReadRegStr $ $ R0 HKCR " .$$ {EXT} " ` $ $ { FileCLASS } _backup `
WriteRegStr HKCR " .$$ {EXT} " " " " $$R0 "
DeleteRegKey HKCR ` $ $ { FileCLASS } `
! macroend
2014-11-29 13:56:26 +00:00
2016-07-02 20:00:53 +00:00
; ! macro ASSOCIATE EXT
; ! insertmacro APP_ASSOCIATE " $$ {EXT} " " Syncplay.$$ {EXT} " " $$INSTDIR \ Syncplay.exe, %1% " \
; " Open with Syncplay " " $$INSTDIR \ Syncplay.exe $$ \" % 1$$ \" "
; ! macroend
2014-11-29 13:56:26 +00:00
2013-01-29 19:08:43 +00:00
! macro UNASSOCIATE EXT
! insertmacro APP_UNASSOCIATE " $$ {EXT} " " Syncplay.$$ {EXT} "
! macroend
2014-11-29 13:56:26 +00:00
2013-01-29 12:30:40 +00:00
; Prevents from running more than one instance of installer and sets default state of checkboxes
Function . onInit
2014-06-29 17:18:38 +00:00
System : : Call ' kernel32::CreateMutexA(i 0, i 0, t " SyncplayMutex " ) i .r1 ?e '
2013-01-29 12:30:40 +00:00
Pop $ $ R0
StrCmp $ $ R0 0 + 3
MessageBox MB_OK | MB_ICONEXCLAMATION " The installer is already running. "
Abort
2014-06-29 17:18:38 +00:00
2016-07-02 20:00:53 +00:00
; StrCpy $ $ CheckBox_Associate_State $ $ { BST_CHECKED }
2013-01-29 12:30:40 +00:00
StrCpy $ $ CheckBox_StartMenuShortcut_State $ $ { BST_CHECKED }
2014-06-29 17:18:38 +00:00
2013-01-29 18:19:32 +00:00
Call GetSize
2013-01-29 12:30:40 +00:00
Call DriveSpace
2021-10-17 12:40:57 +00:00
$ $ { GetParameters } $ $ 0
ClearErrors
$ $ { GetOptions } $ $ 0 " /LANG= " $ $ 0
$ $ { IfNot } $ $ { Errors }
$ $ { AndIf } $ $ 0 < > 0
StrCpy $ $ LANGUAGE $ $ 0
$ $ { Else }
Call Language
$ $ { EndIf }
2013-01-29 12:30:40 +00:00
FunctionEnd
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
; Language selection dialog
Function Language
Push " "
2023-03-14 20:45:38 +00:00
""" + languagePushString + r """
2013-01-29 12:30:40 +00:00
Push A ; A means auto count languages
2014-06-29 19:56:18 +00:00
LangDLL : : LangDialog " Language Selection " " Please select the language of Syncplay and the installer "
2013-01-29 12:30:40 +00:00
Pop $ $ LANGUAGE
StrCmp $ $ LANGUAGE " cancel " 0 + 2
Abort
FunctionEnd
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
Function DirectoryCustom
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
nsDialogs : : Create 1018
Pop $ $ Dialog
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
GetFunctionAddress $ $ R8 DirectoryCustomLeave
nsDialogs : : OnBack $ $ R8
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
$ $ { NSD_CreateIcon } 0 u 0 u 22 u 20 u " "
2013-01-29 14:15:40 +00:00
Pop $ $ Icon_Syncplay
$ $ { NSD_SetIconFromInstaller } $ $ Icon_Syncplay $ $ Icon_Syncplay_Handle
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
$ $ { NSD_CreateLabel } 25 u 0 u 241 u 34 u " $$(^DirText) "
Pop $ $ Label_Text
2014-06-29 17:18:38 +00:00
$ $ { NSD_CreateText } 8 u 38 u 187 u 12 u " $$INSTDIR "
2013-01-29 12:30:40 +00:00
Pop $ $ Text_Directory
$ $ { NSD_SetFocus } $ $ Text_Directory
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
$ $ { NSD_CreateBrowseButton } 202 u 37 u 55 u 14 u " $$(^BrowseBtn) "
Pop $ $ Button_Browse
$ $ { NSD_OnClick } $ $ Button_Browse DirectoryBrowseDialog
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
$ $ { NSD_CreateGroupBox } 1 u 27 u 264 u 30 u " $$(^DirSubText) "
Pop $ $ GroupBox_DirSub
2015-01-03 13:58:18 +00:00
$ $ { NSD_CreateLabel } 0 u 122 u 132 8 u " $$(^SpaceRequired)$$SizeMB "
2013-01-29 12:30:40 +00:00
Pop $ $ Label_Size
2014-06-29 17:18:38 +00:00
2015-01-03 13:58:18 +00:00
$ $ { NSD_CreateLabel } 321 u 122 u 132 8 u " $$(^SpaceAvailable)$$AvailibleSpaceGiB.$$AvailibleSpaceGB "
2013-01-29 12:30:40 +00:00
Pop $ $ Label_Space
2014-06-29 17:18:38 +00:00
2016-07-02 20:00:53 +00:00
; $ $ { NSD_CreateCheckBox } 8 u 59 u 187 u 10 u " $$(^Associate) "
; Pop $ $ CheckBox_Associate
2014-06-29 17:18:38 +00:00
2019-02-02 01:21:56 +00:00
$ $ { NSD_CreateCheckBox } 8 u 72 u 250 u 10 u " $$(^AutomaticUpdates) "
2015-01-03 13:58:18 +00:00
Pop $ $ CheckBox_AutomaticUpdates
$ $ { NSD_Check } $ $ CheckBox_AutomaticUpdates
2019-02-02 01:21:56 +00:00
$ $ { NSD_CreateLabel } 8 u 95 u 187 u 10 u " $$(^Shortcut) "
2013-01-29 12:30:40 +00:00
Pop $ $ Label_Shortcut
2014-06-29 17:18:38 +00:00
2020-11-29 18:04:48 +00:00
$ $ { NSD_CreateCheckbox } 8 u 105 u 70 u 10 u " $$(^StartMenu) "
2013-01-29 12:30:40 +00:00
Pop $ $ CheckBox_StartMenuShortcut
2019-02-02 01:21:56 +00:00
$ $ { NSD_CreateCheckbox } 78 u 105 u 70 u 10 u " $$(^Desktop) "
2013-01-29 12:30:40 +00:00
Pop $ $ CheckBox_DesktopShortcut
2014-06-29 17:18:38 +00:00
2019-02-02 01:21:56 +00:00
$ $ { NSD_CreateCheckbox } 158 u 105 u 130 u 10 u " $$(^QuickLaunchBar) "
2013-01-29 12:30:40 +00:00
Pop $ $ CheckBox_QuickLaunchShortcut
2014-06-29 17:18:38 +00:00
2016-07-02 20:00:53 +00:00
; $ $ { If } $ $ CheckBox_Associate_State == $ $ { BST_CHECKED }
; $ $ { NSD_Check } $ $ CheckBox_Associate
; $ $ { EndIf }
2013-01-29 12:30:40 +00:00
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
$ $ { If } $ $ CheckBox_StartMenuShortcut_State == $ $ { BST_CHECKED }
2018-07-23 21:08:44 +00:00
$ $ { NSD_Check } $ $ CheckBox_StartMenuShortcut
2013-01-29 12:30:40 +00:00
$ $ { EndIf }
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
$ $ { If } $ $ CheckBox_DesktopShortcut_State == $ $ { BST_CHECKED }
2018-07-23 21:08:44 +00:00
$ $ { NSD_Check } $ $ CheckBox_DesktopShortcut
2013-01-29 12:30:40 +00:00
$ $ { EndIf }
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
$ $ { If } $ $ CheckBox_QuickLaunchShortcut_State == $ $ { BST_CHECKED }
2018-07-23 21:08:44 +00:00
$ $ { NSD_Check } $ $ CheckBox_QuickLaunchShortcut
2013-01-29 12:30:40 +00:00
$ $ { EndIf }
2014-06-29 17:18:38 +00:00
2015-01-03 13:58:18 +00:00
$ $ { If } $ $ CheckBox_AutomaticUpdates_State == $ $ { BST_CHECKED }
2018-07-23 21:08:44 +00:00
$ $ { NSD_Check } $ $ CheckBox_AutomaticUpdates
2015-01-03 13:58:18 +00:00
$ $ { EndIf }
2013-01-29 12:30:40 +00:00
nsDialogs : : Show
2013-01-29 14:15:40 +00:00
$ $ { NSD_FreeIcon } $ $ Icon_Syncplay_Handle
2013-01-29 12:30:40 +00:00
FunctionEnd
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
Function DirectoryCustomLeave
2013-01-29 17:49:41 +00:00
$ $ { NSD_GetText } $ $ Text_Directory $ $ INSTDIR
2016-07-02 20:00:53 +00:00
; $ $ { NSD_GetState } $ $ CheckBox_Associate $ $ CheckBox_Associate_State
2015-01-03 13:58:18 +00:00
$ $ { NSD_GetState } $ $ CheckBox_AutomaticUpdates $ $ CheckBox_AutomaticUpdates_State
2013-01-29 12:30:40 +00:00
$ $ { NSD_GetState } $ $ CheckBox_StartMenuShortcut $ $ CheckBox_StartMenuShortcut_State
$ $ { NSD_GetState } $ $ CheckBox_DesktopShortcut $ $ CheckBox_DesktopShortcut_State
$ $ { NSD_GetState } $ $ CheckBox_QuickLaunchShortcut $ $ CheckBox_QuickLaunchShortcut_State
FunctionEnd
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
Function DirectoryBrowseDialog
2014-06-29 17:18:38 +00:00
nsDialogs : : SelectFolderDialog $ $ ( ^ DirBrowseText )
2013-01-29 12:30:40 +00:00
Pop $ $ Directory
$ $ { If } $ $ Directory != error
StrCpy $ $ INSTDIR $ $ Directory
$ $ { NSD_SetText } $ $ Text_Directory $ $ INSTDIR
Call DriveSpace
$ $ { NSD_SetText } $ $ Label_Space " $$(^SpaceAvailable)$$AvailibleSpaceGiB.$$AvailibleSpaceGB "
$ $ { EndIf }
Abort
FunctionEnd
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
Function GetSize
2013-01-29 18:19:32 +00:00
StrCpy $ $ Size " $totalSize "
IntOp $ $ Size $ $ Size / 1024
2013-01-29 12:30:40 +00:00
IntFmt $ $ SizeHex " 0x %08X " $ $ Size
IntOp $ $ Size $ $ Size / 1024
FunctionEnd
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
; Calculates Free Space on HDD
Function DriveSpace
StrCpy $ $ Drive $ $ INSTDIR 1
$ $ { DriveSpace } " $$Drive: \" " / D = F / S = M " $$AvailibleSpace
IntOp $ $ AvailibleSpaceGiB $ $ AvailibleSpace / 1024
IntOp $ $ AvailibleSpace $ $ AvailibleSpace % 1024
IntOp $ $ AvailibleSpace $ $ AvailibleSpace / 102
FunctionEnd
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
Function InstallOptions
2016-07-02 20:00:53 +00:00
; $ $ { If } $ $ CheckBox_Associate_State == $ $ { BST_CHECKED }
; Call Associate
; DetailPrint " Associated Syncplay with multimedia files "
; $ $ { EndIf }
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
$ $ { If } $ $ CheckBox_StartMenuShortcut_State == $ $ { BST_CHECKED }
CreateDirectory $ $ SMPROGRAMS \Syncplay
2019-06-22 22:43:21 +00:00
SetOutPath " $$INSTDIR "
2014-06-29 17:18:38 +00:00
CreateShortCut " $$SMPROGRAMS \ Syncplay \ Syncplay.lnk " " $$INSTDIR \ Syncplay.exe " " "
CreateShortCut " $$SMPROGRAMS \ Syncplay \ Syncplay Server.lnk " " $$INSTDIR \ syncplayServer.exe " " "
2013-01-29 12:30:40 +00:00
CreateShortCut " $$SMPROGRAMS \ Syncplay \ Uninstall.lnk " " $$INSTDIR \ Uninstall.exe " " "
2018-07-17 21:32:49 +00:00
WriteINIStr " $$SMPROGRAMS \ Syncplay \ SyncplayWebsite.url " " InternetShortcut " " URL " " https://syncplay.pl "
2013-01-29 12:30:40 +00:00
$ $ { EndIf }
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
$ $ { If } $ $ CheckBox_DesktopShortcut_State == $ $ { BST_CHECKED }
2019-06-22 22:43:21 +00:00
SetOutPath " $$INSTDIR "
2013-01-29 12:30:40 +00:00
CreateShortCut " $$DESKTOP \ Syncplay.lnk " " $$INSTDIR \ Syncplay.exe " " "
$ $ { EndIf }
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
$ $ { If } $ $ CheckBox_QuickLaunchShortcut_State == $ $ { BST_CHECKED }
2019-06-22 22:43:21 +00:00
SetOutPath " $$INSTDIR "
2013-01-29 12:30:40 +00:00
CreateShortCut " $$QUICKLAUNCH \ Syncplay.lnk " " $$INSTDIR \ Syncplay.exe " " "
$ $ { EndIf }
FunctionEnd
2014-06-29 17:18:38 +00:00
2013-01-15 18:27:21 +00:00
; Associates extensions with Syncplay
2016-07-02 20:00:53 +00:00
; Function Associate
; ! insertmacro ASSOCIATE avi
; ! insertmacro ASSOCIATE mpg
; ! insertmacro ASSOCIATE mpeg
; ! insertmacro ASSOCIATE mpe
; ! insertmacro ASSOCIATE m1v
; ! insertmacro ASSOCIATE m2v
; ! insertmacro ASSOCIATE mpv2
; ! insertmacro ASSOCIATE mp2v
; ! insertmacro ASSOCIATE mkv
; ! insertmacro ASSOCIATE mp4
; ! insertmacro ASSOCIATE m4v
; ! insertmacro ASSOCIATE mp4v
; ! insertmacro ASSOCIATE 3 gp
; ! insertmacro ASSOCIATE 3 gpp
; ! insertmacro ASSOCIATE 3 g2
; ! insertmacro ASSOCIATE 3 pg2
; ! insertmacro ASSOCIATE flv
; ! insertmacro ASSOCIATE f4v
; ! insertmacro ASSOCIATE rm
; ! insertmacro ASSOCIATE wmv
; ! insertmacro ASSOCIATE swf
; ! insertmacro ASSOCIATE rmvb
; ! insertmacro ASSOCIATE divx
; ! insertmacro ASSOCIATE amv
; FunctionEnd
2014-06-29 17:18:38 +00:00
2013-01-15 18:27:21 +00:00
Function WriteRegistry
2013-01-29 12:30:40 +00:00
Call GetSize
2013-01-15 18:27:21 +00:00
WriteRegStr HKLM SOFTWARE \Syncplay " Install_Dir " " $$INSTDIR "
WriteRegStr HKLM " Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ Syncplay " " DisplayName " " Syncplay "
2014-06-29 17:18:38 +00:00
WriteRegStr HKLM " Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ Syncplay " " InstallLocation " " $$INSTDIR "
2013-01-15 18:27:21 +00:00
WriteRegStr HKLM " Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ Syncplay " " UninstallString " ' " $$INSTDIR \ uninstall.exe " '
2013-01-26 21:10:28 +00:00
WriteRegStr HKLM " Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ Syncplay " " DisplayIcon " " $$INSTDIR \r esources \ icon.ico "
2013-01-15 18:27:21 +00:00
WriteRegStr HKLM " Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ Syncplay " " Publisher " " Syncplay "
2013-01-26 21:10:28 +00:00
WriteRegStr HKLM " Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ Syncplay " " DisplayVersion " " $version "
2018-03-22 18:05:32 +00:00
WriteRegStr HKLM " Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ Syncplay " " URLInfoAbout " " https://syncplay.pl/ "
2013-01-15 18:27:21 +00:00
WriteRegDWORD HKLM " Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ Syncplay " " NoModify " 1
WriteRegDWORD HKLM " Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ Syncplay " " NoRepair " 1
2013-01-29 12:30:40 +00:00
WriteRegDWORD HKLM " Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ Syncplay " " EstimatedSize " " $$SizeHex "
2014-06-29 19:56:18 +00:00
WriteINIStr $ $ APPDATA \syncplay . ini general language $ $ ( ^ SyncplayLanguage )
2015-01-03 13:58:18 +00:00
$ $ { If } $ $ CheckBox_AutomaticUpdates_State == $ $ { BST_CHECKED }
WriteINIStr $ $ APPDATA \syncplay . ini general CheckForUpdatesAutomatically " True "
$ $ { Else }
WriteINIStr $ $ APPDATA \syncplay . ini general CheckForUpdatesAutomatically " False "
$ $ { EndIf }
2013-01-15 18:27:21 +00:00
FunctionEnd
2014-06-29 17:18:38 +00:00
2013-01-29 14:15:40 +00:00
Function un . installConfirm
nsDialogs : : Create 1018
Pop $ $ Uninst_Dialog
2014-06-29 17:18:38 +00:00
2013-01-29 14:15:40 +00:00
$ $ { NSD_CreateIcon } 0 u 1 u 22 u 20 u " "
Pop $ $ Uninst_Icon
$ $ { NSD_SetIconFromInstaller } $ $ Uninst_Icon $ $ Uninst_Icon_Handle
2014-06-29 17:18:38 +00:00
2013-01-29 14:15:40 +00:00
$ $ { NSD_CreateLabel } 0 u 45 u 55 u 8 u " $$(^UninstallingSubText) "
Pop $ $ Uninst_Label_Directory
2014-06-29 17:18:38 +00:00
2013-01-29 14:15:40 +00:00
$ $ { NSD_CreateLabel } 25 u 0 u 241 u 34 u " $$(^UninstallingText) "
Pop $ $ Uninst_Label_Text
2014-06-29 17:18:38 +00:00
2013-01-29 14:15:40 +00:00
ReadRegStr $ $ INSTDIR HKLM " Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ Syncplay " " InstallLocation "
2014-06-29 17:18:38 +00:00
$ $ { NSD_CreateText } 56 u 43 u 209 u 12 u " $$INSTDIR "
2013-01-29 14:15:40 +00:00
Pop $ $ Uninst_Text_Directory
EnableWindow $ $ Uninst_Text_Directory 0
2014-06-29 17:18:38 +00:00
2013-01-29 14:15:40 +00:00
$ $ { NSD_CreateCheckBox } 0 u 60 u 250 u 10 u " $$(^UninstConfig) "
Pop $ $ Uninst_CheckBox_Config
2014-06-29 17:18:38 +00:00
2013-01-29 14:15:40 +00:00
nsDialogs : : Show
$ $ { NSD_FreeIcon } $ $ Uninst_Icon_Handle
FunctionEnd
2014-06-29 17:18:38 +00:00
2013-01-29 14:15:40 +00:00
Function un . installConfirmLeave
$ $ { NSD_GetState } $ $ Uninst_CheckBox_Config $ $ Uninst_CheckBox_Config_State
FunctionEnd
2014-06-29 17:18:38 +00:00
2013-01-15 18:27:21 +00:00
Function un . AssociateDel
2013-01-29 19:08:43 +00:00
! insertmacro UNASSOCIATE avi
! insertmacro UNASSOCIATE mpg
! insertmacro UNASSOCIATE mpeg
! insertmacro UNASSOCIATE mpe
! insertmacro UNASSOCIATE m1v
! insertmacro UNASSOCIATE m2v
! insertmacro UNASSOCIATE mpv2
! insertmacro UNASSOCIATE mp2v
! insertmacro UNASSOCIATE mkv
! insertmacro UNASSOCIATE mp4
! insertmacro UNASSOCIATE m4v
! insertmacro UNASSOCIATE mp4v
! insertmacro UNASSOCIATE 3 gp
! insertmacro UNASSOCIATE 3 gpp
! insertmacro UNASSOCIATE 3 g2
! insertmacro UNASSOCIATE 3 pg2
! insertmacro UNASSOCIATE flv
! insertmacro UNASSOCIATE f4v
! insertmacro UNASSOCIATE rm
! insertmacro UNASSOCIATE wmv
! insertmacro UNASSOCIATE swf
! insertmacro UNASSOCIATE rmvb
! insertmacro UNASSOCIATE divx
2014-06-29 17:18:38 +00:00
! insertmacro UNASSOCIATE amv
2013-01-15 18:27:21 +00:00
FunctionEnd
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
Function un . InstallOptions
Delete $ $ SMPROGRAMS \Syncplay \Syncplay . lnk
2014-06-29 17:18:38 +00:00
Delete " $$SMPROGRAMS \ Syncplay \ Syncplay Server.lnk "
2013-01-29 12:30:40 +00:00
Delete $ $ SMPROGRAMS \Syncplay \Uninstall . lnk
Delete $ $ SMPROGRAMS \Syncplay \SyncplayWebsite . url
RMDir $ $ SMPROGRAMS \Syncplay
Delete $ $ DESKTOP \Syncplay . lnk
Delete $ $ QUICKLAUNCH \Syncplay . lnk
2014-06-29 17:18:38 +00:00
ReadRegStr $ $ VLC_Directory HKLM " Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ Syncplay " " VLCInstallLocation "
IfFileExists " $$VLC_Directory \ lua \ intf \ syncplay.lua " 0 + 2
2013-01-29 12:30:40 +00:00
Delete $ $ VLC_Directory \lua \intf \syncplay . lua
2013-01-15 18:27:21 +00:00
FunctionEnd
2014-11-29 13:56:26 +00:00
2013-01-29 18:19:32 +00:00
Section " Install "
2013-01-15 18:27:21 +00:00
SetOverwrite on
SetOutPath $ $ INSTDIR
WriteUninstaller uninstall . exe
2014-11-29 13:56:26 +00:00
2013-01-16 14:00:57 +00:00
$ installFiles
2014-11-29 13:56:26 +00:00
2013-01-29 12:30:40 +00:00
Call InstallOptions
2013-01-26 21:10:28 +00:00
Call WriteRegistry
2013-01-15 18:27:21 +00:00
SectionEnd
2014-11-29 13:56:26 +00:00
2013-01-15 18:27:21 +00:00
Section " Uninstall "
Call un . AssociateDel
2013-01-29 12:30:40 +00:00
Call un . InstallOptions
2013-01-26 19:30:43 +00:00
$ uninstallFiles
2013-01-15 18:27:21 +00:00
DeleteRegKey HKLM " Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ Syncplay "
DeleteRegKey HKLM SOFTWARE \Syncplay
Delete $ $ INSTDIR \uninstall . exe
2014-06-29 17:18:38 +00:00
RMDir $ $ INSTDIR \Syncplay \\resources \lua \intf
RMDir $ $ INSTDIR \Syncplay \\resources \lua
RMDir $ $ INSTDIR \Syncplay \\resources
2013-01-26 21:17:40 +00:00
RMDir $ $ INSTDIR \resources
RMDir $ $ INSTDIR \lib
2013-01-29 14:15:40 +00:00
RMDir $ $ INSTDIR
$ $ { If } $ $ Uninst_CheckBox_Config_State == $ $ { BST_CHECKED }
2014-06-29 17:18:38 +00:00
IfFileExists " $$APPDATA \ .syncplay " 0 + 2
2013-01-29 14:15:40 +00:00
Delete $ $ APPDATA \. syncplay
2014-06-29 17:18:38 +00:00
IfFileExists " $$APPDATA \ syncplay.ini " 0 + 2
Delete $ $ APPDATA \syncplay . ini
2013-01-29 14:15:40 +00:00
$ $ { EndIf }
2013-01-15 18:27:21 +00:00
SectionEnd
"""
class NSISScript ( object ) :
def create ( self ) :
2013-01-29 18:19:32 +00:00
fileList , totalSize = self . getBuildDirContents ( OUT_DIR )
2018-04-23 22:44:19 +00:00
print ( " Total size eq: {} " . format ( totalSize ) )
2018-07-23 21:08:44 +00:00
installFiles = self . prepareInstallListTemplate ( fileList )
2013-01-16 14:00:57 +00:00
uninstallFiles = self . prepareDeleteListTemplate ( fileList )
2018-07-23 21:08:44 +00:00
2014-07-02 22:20:31 +00:00
if os . path . isfile ( SETUP_SCRIPT_PATH ) :
2013-01-15 18:27:21 +00:00
raise RuntimeError ( " Cannot create setup script, file exists at {} " . format ( SETUP_SCRIPT_PATH ) )
2018-07-23 21:08:44 +00:00
contents = Template ( NSIS_SCRIPT_TEMPLATE ) . substitute (
version = syncplay . version ,
uninstallFiles = uninstallFiles ,
installFiles = installFiles ,
totalSize = totalSize ,
)
2016-12-03 20:52:02 +00:00
with codecs . open ( SETUP_SCRIPT_PATH , " w " , " utf-8-sig " ) as outfile :
2018-06-18 15:02:03 +00:00
outfile . write ( contents )
2018-07-23 21:08:44 +00:00
2013-01-15 18:27:21 +00:00
def compile ( self ) :
2014-07-02 22:20:31 +00:00
if not os . path . isfile ( NSIS_COMPILE ) :
2013-01-29 18:19:32 +00:00
return " makensis.exe not found, won ' t create the installer "
2013-01-15 18:27:21 +00:00
subproc = subprocess . Popen ( [ NSIS_COMPILE , SETUP_SCRIPT_PATH ] , env = os . environ )
subproc . communicate ( )
retcode = subproc . returncode
os . remove ( SETUP_SCRIPT_PATH )
if retcode :
raise RuntimeError ( " NSIS compilation return code: %d " % retcode )
2018-07-23 21:08:44 +00:00
2013-01-16 14:00:57 +00:00
def getBuildDirContents ( self , path ) :
fileList = { }
2013-01-29 18:19:32 +00:00
totalSize = 0
2013-01-16 14:00:57 +00:00
for root , _ , files in os . walk ( path ) :
2013-01-29 18:19:32 +00:00
totalSize + = sum ( os . path . getsize ( os . path . join ( root , file_ ) ) for file_ in files )
2013-01-16 14:00:57 +00:00
for file_ in files :
new_root = root . replace ( OUT_DIR , " " ) . strip ( " \\ " )
2018-04-23 22:44:19 +00:00
if new_root not in fileList :
2013-01-16 14:00:57 +00:00
fileList [ new_root ] = [ ]
fileList [ new_root ] . append ( file_ )
2018-07-23 21:08:44 +00:00
return fileList , totalSize
2013-01-16 14:00:57 +00:00
def prepareInstallListTemplate ( self , fileList ) :
create = [ ]
2018-04-23 22:44:19 +00:00
for dir_ in fileList . keys ( ) :
2013-01-16 14:00:57 +00:00
create . append ( ' SetOutPath " $INSTDIR \\ {} " ' . format ( dir_ ) )
for file_ in fileList [ dir_ ] :
create . append ( ' FILE " {} \\ {} \\ {} " ' . format ( OUT_DIR , dir_ , file_ ) )
return " \n " . join ( create )
2018-07-23 21:08:44 +00:00
2013-01-16 14:00:57 +00:00
def prepareDeleteListTemplate ( self , fileList ) :
delete = [ ]
2018-04-23 22:44:19 +00:00
for dir_ in fileList . keys ( ) :
2013-01-16 14:00:57 +00:00
for file_ in fileList [ dir_ ] :
delete . append ( ' DELETE " $INSTDIR \\ {} \\ {} " ' . format ( dir_ , file_ ) )
2018-07-23 21:08:44 +00:00
delete . append ( ' RMdir " $INSTDIR \\ {} " ' . format ( file_ ) )
2013-01-16 14:00:57 +00:00
return " \n " . join ( delete )
2018-07-23 21:08:44 +00:00
2018-07-29 15:15:20 +00:00
def pruneUnneededLibraries ( ) :
from pathlib import Path
cwd = os . getcwd ( )
libDir = cwd + ' \\ ' + OUT_DIR + ' \\ lib \\ '
unneededModules = [ ' PySide2.Qt3D* ' , ' PySide2.QtAxContainer.pyd ' , ' PySide2.QtCharts.pyd ' , ' PySide2.QtConcurrent.pyd ' ,
' PySide2.QtDataVisualization.pyd ' , ' PySide2.QtHelp.pyd ' , ' PySide2.QtLocation.pyd ' ,
' PySide2.QtMultimedia.pyd ' , ' PySide2.QtMultimediaWidgets.pyd ' , ' PySide2.QtOpenGL.pyd ' ,
' PySide2.QtPositioning.pyd ' , ' PySide2.QtPrintSupport.pyd ' , ' PySide2.QtQml.pyd ' ,
' PySide2.QtQuick.pyd ' , ' PySide2.QtQuickWidgets.pyd ' , ' PySide2.QtScxml.pyd ' , ' PySide2.QtSensors.pyd ' ,
' PySide2.QtSql.pyd ' , ' PySide2.QtSvg.pyd ' , ' PySide2.QtTest.pyd ' , ' PySide2.QtTextToSpeech.pyd ' ,
2019-01-11 19:15:05 +00:00
' PySide2.QtUiTools.pyd ' , ' PySide2.QtWebChannel.pyd ' , ' PySide2.QtWebEngine.pyd ' ,
' PySide2.QtWebEngineCore.pyd ' , ' PySide2.QtWebEngineWidgets.pyd ' , ' PySide2.QtWebSockets.pyd ' ,
2018-07-29 15:15:20 +00:00
' PySide2.QtWinExtras.pyd ' , ' PySide2.QtXml.pyd ' , ' PySide2.QtXmlPatterns.pyd ' ]
unneededLibs = [ ' Qt53D* ' , ' Qt5Charts.dll ' , ' Qt5Concurrent.dll ' , ' Qt5DataVisualization.dll ' , ' Qt5Gamepad.dll ' , ' Qt5Help.dll ' ,
' Qt5Location.dll ' , ' Qt5Multimedia.dll ' , ' Qt5MultimediaWidgets.dll ' , ' Qt5OpenGL.dll ' , ' Qt5Positioning.dll ' ,
' Qt5PrintSupport.dll ' , ' Qt5Quick.dll ' , ' Qt5QuickWidgets.dll ' , ' Qt5Scxml.dll ' , ' Qt5Sensors.dll ' , ' Qt5Sql.dll ' ,
2019-01-11 19:15:05 +00:00
' Qt5Svg.dll ' , ' Qt5Test.dll ' , ' Qt5TextToSpeech.dll ' , ' Qt5WebChannel.dll ' , ' Qt5WebEngine.dll ' ,
' Qt5WebEngineCore.dll ' , ' Qt5WebEngineWidgets.dll ' , ' Qt5WebSockets.dll ' , ' Qt5WinExtras.dll ' , ' Qt5Xml.dll ' ,
' Qt5XmlPatterns.dll ' ]
2018-07-29 15:15:20 +00:00
windowsDLL = [ ' MSVCP140.dll ' , ' VCRUNTIME140.dll ' ]
deleteList = unneededModules + unneededLibs + windowsDLL
deleteList . append ( ' api-* ' )
for filename in deleteList :
for p in Path ( libDir ) . glob ( filename ) :
p . unlink ( )
def copyQtPlugins ( paths ) :
import shutil
from PySide2 import QtCore
basePath = QtCore . QLibraryInfo . location ( QtCore . QLibraryInfo . PluginsPath )
basePath = basePath . replace ( ' / ' , ' \\ ' )
destBase = os . getcwd ( ) + ' \\ ' + OUT_DIR
for elem in paths :
elemDir , elemName = os . path . split ( elem )
source = basePath + ' \\ ' + elem
dest = destBase + ' \\ ' + elem
destDir = destBase + ' \\ ' + elemDir
os . makedirs ( destDir , exist_ok = True )
shutil . copy ( source , dest )
2018-07-23 21:08:44 +00:00
2013-01-15 18:27:21 +00:00
class build_installer ( py2exe ) :
def run ( self ) :
py2exe . run ( self )
2018-07-29 15:15:20 +00:00
print ( ' *** deleting unnecessary libraries and modules *** ' )
pruneUnneededLibraries ( )
print ( ' *** copying qt plugins *** ' )
copyQtPlugins ( qt_plugins )
2013-01-15 18:27:21 +00:00
script = NSISScript ( )
script . create ( )
2018-07-29 15:15:20 +00:00
print ( " *** compiling the NSIS setup script *** " )
2013-01-15 18:27:21 +00:00
script . compile ( )
2018-04-23 22:44:19 +00:00
print ( " *** DONE *** " )
2013-01-15 18:27:21 +00:00
2019-08-19 17:03:38 +00:00
guiIcons = glob ( ' syncplay/resources/*.ico ' ) + glob ( ' syncplay/resources/*.png ' ) + [ ' syncplay/resources/spinner.mng ' ]
2019-04-13 13:39:55 +00:00
2018-07-23 21:08:44 +00:00
resources = [
2019-04-13 13:39:55 +00:00
" syncplay/resources/syncplayintf.lua " ,
" syncplay/resources/license.rtf " ,
2021-03-28 20:08:51 +00:00
" syncplay/resources/third-party-notices.txt "
2018-07-23 21:08:44 +00:00
]
2013-06-08 16:57:57 +00:00
resources . extend ( guiIcons )
2019-04-13 13:39:55 +00:00
intf_resources = [ " syncplay/resources/lua/intf/syncplay.lua " ]
2013-06-08 16:57:57 +00:00
2018-07-29 15:15:20 +00:00
qt_plugins = [ ' platforms \\ qwindows.dll ' , ' styles \\ qwindowsvistastyle.dll ' ]
2012-10-12 16:37:12 +00:00
common_info = dict (
2012-10-15 18:33:24 +00:00
name = ' Syncplay ' ,
version = syncplay . version ,
2012-12-26 16:03:57 +00:00
author = ' Uriziel ' ,
2014-06-29 17:18:38 +00:00
author_email = ' dev@syncplay.pl ' ,
2012-10-15 18:33:24 +00:00
description = ' Syncplay ' ,
2012-10-12 16:37:12 +00:00
)
2018-07-23 21:08:44 +00:00
2012-10-12 16:37:12 +00:00
info = dict (
common_info ,
2018-07-23 21:08:44 +00:00
windows = [ {
2022-07-31 15:35:33 +00:00
" script " : " syncplayClient.py " ,
" icon_resources " : [ ( 1 , " syncplay \\ resources \\ icon.ico " ) ] ,
' dest_base ' : " Syncplay " } ,
2018-07-23 21:08:44 +00:00
] ,
2013-06-08 13:00:44 +00:00
console = [ ' syncplayServer.py ' ] ,
2014-08-09 16:47:31 +00:00
# *** 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"}],
2018-07-29 15:15:20 +00:00
2018-07-23 21:08:44 +00:00
options = {
' py2exe ' : {
' dist_dir ' : OUT_DIR ,
2019-04-13 13:39:55 +00:00
' packages ' : ' PySide2, cffi, OpenSSL, certifi ' ,
2022-04-29 09:49:36 +00:00
' includes ' : ' twisted, sys, encodings, datetime, os, time, math, urllib, ast, unicodedata, _ssl, win32pipe, win32file, sqlite3 ' ,
2021-03-07 19:25:23 +00:00
' excludes ' : ' venv, doctest, pdb, unittest, win32clipboard, win32pdh, win32security, win32trace, win32ui, winxpgui, win32process, tcl, tkinter ' ,
2018-07-23 21:08:44 +00:00
' dll_excludes ' : ' msvcr71.dll, MSVCP90.dll, POWRPROF.dll ' ,
' optimize ' : 2 ,
' compressed ' : 1
}
} ,
data_files = [ ( " resources " , resources ) , ( " resources/lua/intf " , intf_resources ) ] ,
2021-03-07 19:25:23 +00:00
zipfile = " lib/libsync.zip " ,
2018-07-23 21:08:44 +00:00
cmdclass = { " py2exe " : build_installer } ,
2012-10-12 16:37:12 +00:00
)
2019-04-13 13:39:55 +00:00
sys . argv . extend ( [ ' py2exe ' ] )
2019-12-30 12:56:27 +00:00
setup ( * * info )