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
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
2018-07-23 20:32:47 +00:00
from syncplay . messages import getMissingStrings
2018-07-23 21:08:44 +00:00
2014-11-30 17:58:03 +00:00
missingStrings = getMissingStrings ( )
if missingStrings is not None and missingStrings is not " " :
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 "
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
2013-01-15 18:27:21 +00:00
LoadLanguageFile " $$ {NSISDIR} \ Contrib \ Language files \ English.nlf "
LoadLanguageFile " $$ {NSISDIR} \ Contrib \ Language files \ Polish.nlf "
2014-10-14 11:56:08 +00:00
LoadLanguageFile " $$ {NSISDIR} \ Contrib \ Language files \ Russian.nlf "
2014-11-29 15:01:45 +00:00
LoadLanguageFile " $$ {NSISDIR} \ Contrib \ Language files \ German.nlf "
2018-02-09 19:14:37 +00:00
LoadLanguageFile " $$ {NSISDIR} \ Contrib \ Language files \ Italian.nlf "
2014-11-29 13:56:26 +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
XPStyle on
Icon resources \icon . ico ; Change DIR
SetCompressor / SOLID lzma
2014-11-29 13:56:26 +00:00
2013-01-16 14:00:57 +00:00
VIProductVersion " $version.0 "
2013-01-15 18:27:21 +00:00
VIAddVersionKey / LANG = $ $ { LANG_ENGLISH } " ProductName " " Syncplay "
2013-01-16 14:00:57 +00:00
VIAddVersionKey / LANG = $ $ { LANG_ENGLISH } " FileVersion " " $version.0 "
2013-01-15 18:27:21 +00:00
VIAddVersionKey / LANG = $ $ { LANG_ENGLISH } " LegalCopyright " " Syncplay "
VIAddVersionKey / LANG = $ $ { LANG_ENGLISH } " FileDescription " " Syncplay "
2014-11-29 13:56:26 +00:00
2013-01-15 18:27:21 +00:00
VIAddVersionKey / LANG = $ $ { LANG_POLISH } " ProductName " " Syncplay "
2013-01-16 14:00:57 +00:00
VIAddVersionKey / LANG = $ $ { LANG_POLISH } " FileVersion " " $version.0 "
2013-01-15 18:27:21 +00:00
VIAddVersionKey / LANG = $ $ { LANG_POLISH } " LegalCopyright " " Syncplay "
2013-01-29 12:30:40 +00:00
VIAddVersionKey / LANG = $ $ { LANG_POLISH } " FileDescription " " Syncplay "
2014-11-29 13:56:26 +00:00
2014-10-14 11:56:08 +00:00
VIAddVersionKey / LANG = $ $ { LANG_RUSSIAN } " ProductName " " Syncplay "
VIAddVersionKey / LANG = $ $ { LANG_RUSSIAN } " FileVersion " " $version.0 "
VIAddVersionKey / LANG = $ $ { LANG_RUSSIAN } " LegalCopyright " " Syncplay "
VIAddVersionKey / LANG = $ $ { LANG_RUSSIAN } " FileDescription " " Syncplay "
2018-07-23 21:08:44 +00:00
2018-02-09 19:14:37 +00:00
VIAddVersionKey / LANG = $ $ { LANG_ITALIAN } " ProductName " " Syncplay "
VIAddVersionKey / LANG = $ $ { LANG_ITALIAN } " FileVersion " " $version.0 "
VIAddVersionKey / LANG = $ $ { LANG_ITALIAN } " LegalCopyright " " Syncplay "
VIAddVersionKey / LANG = $ $ { LANG_ITALIAN } " FileDescription " " Syncplay "
2014-11-29 13:56:26 +00:00
2014-06-29 19:56:18 +00:00
LangString ^ SyncplayLanguage $ $ { LANG_ENGLISH } " en "
2013-01-29 12:30:40 +00:00
LangString ^ Associate $ $ { LANG_ENGLISH } " Associate Syncplay with multimedia files. "
2014-06-29 17:18:38 +00:00
LangString ^ VLC $ $ { LANG_ENGLISH } " Install Syncplay interface for VLC 2 and above "
LangString ^ BrowseVLCBtn $ $ { LANG_ENGLISH } " Select VLC folder "
2013-01-29 12:30:40 +00:00
LangString ^ Shortcut $ $ { LANG_ENGLISH } " Create Shortcuts in following locations: "
LangString ^ StartMenu $ $ { LANG_ENGLISH } " Start Menu "
LangString ^ Desktop $ $ { LANG_ENGLISH } " Desktop "
LangString ^ QuickLaunchBar $ $ { LANG_ENGLISH } " Quick Launch Bar "
2015-01-03 13:58:18 +00:00
LangString ^ AutomaticUpdates $ $ { LANG_ENGLISH } " Check for updates automatically "
2013-01-29 14:15:40 +00:00
LangString ^ UninstConfig $ $ { LANG_ENGLISH } " Delete configuration file. "
2014-11-29 13:56:26 +00:00
2014-06-29 19:56:18 +00:00
LangString ^ SyncplayLanguage $ $ { LANG_POLISH } " pl "
2013-01-29 12:30:40 +00:00
LangString ^ Associate $ $ { LANG_POLISH } " Skojarz Syncplaya z multimediami "
2014-06-29 17:18:38 +00:00
LangString ^ VLC $ $ { LANG_POLISH } " Zainstaluj interface Syncplaya dla VLC 2+ "
LangString ^ BrowseVLCBtn $ $ { LANG_POLISH } " Określ folder VLC "
2013-01-29 12:30:40 +00:00
LangString ^ Shortcut $ $ { LANG_POLISH } " Utworz skroty w nastepujacych miejscach: "
LangString ^ StartMenu $ $ { LANG_POLISH } " Menu Start "
LangString ^ Desktop $ $ { LANG_POLISH } " Pulpit "
LangString ^ QuickLaunchBar $ $ { LANG_POLISH } " Pasek szybkiego uruchamiania "
2013-01-29 14:15:40 +00:00
LangString ^ UninstConfig $ $ { LANG_POLISH } " Usun plik konfiguracyjny. "
2014-11-29 13:56:26 +00:00
2014-10-14 11:56:08 +00:00
LangString ^ SyncplayLanguage $ $ { LANG_RUSSIAN } " ru "
LangString ^ Associate $ $ { LANG_RUSSIAN } " Ассоциировать Syncplay с видеофайлами "
LangString ^ VLC $ $ { LANG_RUSSIAN } " Установить интерфейс Syncplay для VLC 2+ "
LangString ^ BrowseVLCBtn $ $ { LANG_RUSSIAN } " Укажите папку VLC "
LangString ^ Shortcut $ $ { LANG_RUSSIAN } " Создать ярлыки: "
LangString ^ StartMenu $ $ { LANG_RUSSIAN } " в меню Пуск "
LangString ^ Desktop $ $ { LANG_RUSSIAN } " на рабочем столе "
LangString ^ QuickLaunchBar $ $ { LANG_RUSSIAN } " в меню быстрого запуска "
2015-01-03 13:58:18 +00:00
LangString ^ AutomaticUpdates $ $ { LANG_RUSSIAN } " Проверять обновления автоматически " ; TODO : Confirm Russian translation ( " Check for updates automatically " )
2014-10-14 11:56:08 +00:00
LangString ^ UninstConfig $ $ { LANG_RUSSIAN } " Удалить файл настроек. "
2014-11-29 13:56:26 +00:00
2014-11-29 15:01:45 +00:00
LangString ^ SyncplayLanguage $ $ { LANG_GERMAN } " de "
2015-10-27 16:17:12 +00:00
LangString ^ Associate $ $ { LANG_GERMAN } " Syncplay als Standardprogramm für Multimedia-Dateien verwenden. "
2014-11-29 15:54:57 +00:00
LangString ^ VLC $ $ { LANG_GERMAN } " Syncplay-Interface für VLC installieren (ab VLC 2+) "
2014-11-29 15:01:45 +00:00
LangString ^ Shortcut $ $ { LANG_GERMAN } " Erstelle Verknüpfungen an folgenden Orten: "
2014-11-29 15:54:57 +00:00
LangString ^ BrowseVLCBtn $ $ { LANG_GERMAN } " VLC-Ordner wählen "
LangString ^ StartMenu $ $ { LANG_GERMAN } " Startmenü "
2014-11-29 15:01:45 +00:00
LangString ^ Desktop $ $ { LANG_GERMAN } " Desktop "
LangString ^ QuickLaunchBar $ $ { LANG_GERMAN } " Schnellstartleiste "
2015-10-06 15:54:11 +00:00
LangString ^ AutomaticUpdates $ $ { LANG_GERMAN } " Automatisch nach Updates suchen " ;
2014-11-29 15:01:45 +00:00
LangString ^ UninstConfig $ $ { LANG_GERMAN } " Konfigurationsdatei löschen. "
2018-07-23 21:08:44 +00:00
2018-02-09 19:14:37 +00:00
LangString ^ SyncplayLanguage $ $ { LANG_ITALIAN } " it "
LangString ^ Associate $ $ { LANG_ITALIAN } " Associa Syncplay con i file multimediali. "
LangString ^ VLC $ $ { LANG_ITALIAN } " Installa l ' interfaccia di Syncplay per VLC 2+ "
LangString ^ BrowseVLCBtn $ $ { LANG_ITALIAN } " Cartella di VLC "
LangString ^ Shortcut $ $ { LANG_ITALIAN } " Crea i collegamenti nei percorsi seguenti: "
LangString ^ StartMenu $ $ { LANG_ITALIAN } " Menu Start "
LangString ^ Desktop $ $ { LANG_ITALIAN } " Desktop "
LangString ^ QuickLaunchBar $ $ { LANG_ITALIAN } " Barra di avvio rapido "
LangString ^ AutomaticUpdates $ $ { LANG_ITALIAN } " Controllo automatico degli aggiornamenti "
LangString ^ UninstConfig $ $ { LANG_ITALIAN } " Cancella i file di configurazione. "
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
2017-09-29 17:14:55 +00:00
LicenseData 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
2013-01-29 12:30:40 +00:00
Var CheckBox_VLC
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
2013-01-29 12:30:40 +00:00
Var CheckBox_VLC_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
2014-06-29 17:18:38 +00:00
Var Button_Browse_VLC
2013-01-29 12:30:40 +00:00
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
Call GetVLCDir
2014-07-14 20:27:10 +00:00
Call UpdateVLCCheckbox
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
Call Language
FunctionEnd
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
; Language selection dialog
Function Language
Push " "
Push $ $ { LANG_ENGLISH }
Push English
Push $ $ { LANG_POLISH }
Push Polski
2018-07-23 21:08:44 +00:00
Push $ $ { LANG_RUSSIAN }
2014-11-29 13:56:26 +00:00
Push Русский
2014-11-29 15:01:45 +00:00
Push $ $ { LANG_GERMAN }
Push Deutsch
2018-07-23 21:08:44 +00:00
Push $ $ { LANG_ITALIAN }
2018-02-09 19:14:37 +00:00
Push Italiano
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
$ $ { NSD_CreateBrowseButton } 185 u 70 u 70 u 14 u " $$(^BrowseVLCBtn) "
Pop $ $ Button_Browse_VLC
$ $ { NSD_OnClick } $ $ Button_Browse_VLC DirectoryBrowseDialogVLC
2013-01-29 12:30:40 +00:00
$ $ { NSD_CreateCheckBox } 8 u 72 u 250 u 10 u " $$(^VLC) "
Pop $ $ CheckBox_VLC
2014-06-29 17:18:38 +00:00
2015-01-03 13:58:18 +00:00
$ $ { NSD_CreateCheckBox } 8 u 85 u 250 u 10 u " $$(^AutomaticUpdates) "
Pop $ $ CheckBox_AutomaticUpdates
$ $ { NSD_Check } $ $ CheckBox_AutomaticUpdates
$ $ { NSD_CreateLabel } 8 u 98 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
2015-01-03 13:58:18 +00:00
$ $ { NSD_CreateCheckbox } 8 u 111 u 60 u 10 u " $$(^StartMenu) "
2013-01-29 12:30:40 +00:00
Pop $ $ CheckBox_StartMenuShortcut
2015-01-03 13:58:18 +00:00
$ $ { NSD_CreateCheckbox } 78 u 111 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
2015-01-03 13:58:18 +00:00
$ $ { NSD_CreateCheckbox } 158 u 111 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
$ $ { If } $ $ CheckBox_VLC_State == $ $ { BST_CHECKED }
2018-07-23 21:08:44 +00:00
$ $ { NSD_Check } $ $ CheckBox_VLC
2013-01-29 12:30:40 +00:00
$ $ { EndIf }
2014-06-29 17:18:38 +00:00
Call UpdateVLCCheckbox
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
2013-01-29 12:30:40 +00:00
$ $ { NSD_GetState } $ $ CheckBox_VLC $ $ CheckBox_VLC_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
Function GetVLCDir
IfFileExists " $$VLC_Directory \v lc.exe " VLCFound 0
ReadRegStr $ $ VLC_Directory HKLM " Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ Syncplay " " VLCInstallLocation "
IfFileExists " $$VLC_Directory \v lc.exe " VLCFound 0
ReadRegStr $ $ VLC_Directory HKLM " Software \ VideoLAN \ VLC " " InstallDir "
IfFileExists " $$VLC_Directory \v lc.exe " VLCFound 0
StrCpy $ $ VLC_Directory " c: \ program files (x86) \v ideolan \v lc "
IfFileExists " $$VLC_Directory \v lc.exe " VLCFound 0
StrCpy $ $ VLC_Directory " c: \ program files \v ideolan \v lc "
IfFileExists " $$VLC_Directory \v lc.exe " VLCFound 0
StrCpy $ $ VLC_Directory " "
VLCFound :
FunctionEnd
Function UpdateVLCCheckbox
IfFileExists " $$VLC_Directory \v lc.exe " VLC_Enabled VLC_Disabled
VLC_Enabled :
EnableWindow $ $ CheckBox_VLC 1
2014-07-14 20:27:10 +00:00
StrCpy $ $ CheckBox_VLC_State $ $ { BST_CHECKED }
$ $ { NSD_SetState } $ $ CheckBox_VLC $ $ CheckBox_VLC_State
2014-06-29 17:18:38 +00:00
goto CheckboxUpdated
VLC_Disabled :
EnableWindow $ $ CheckBox_VLC 0
2014-07-14 20:27:10 +00:00
StrCpy $ $ CheckBox_VLC_State $ $ { BST_UNCHECKED }
$ $ { NSD_SetState } $ $ CheckBox_VLC $ $ CheckBox_VLC_State
2014-06-29 17:18:38 +00:00
CheckboxUpdated :
FunctionEnd
Function DirectoryBrowseDialogVLC
nsDialogs : : SelectFolderDialog $ $ ( ^ BrowseVLCBtn ) $ $ VLC_Directory
Pop $ $ Directory
$ $ { If } $ $ Directory != error
StrCpy $ $ VLC_Directory $ $ Directory
Call UpdateVLCCheckbox
$ $ { EndIf }
Abort
FunctionEnd
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
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 }
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 }
CreateShortCut " $$QUICKLAUNCH \ Syncplay.lnk " " $$INSTDIR \ Syncplay.exe " " "
$ $ { EndIf }
2014-06-29 17:18:38 +00:00
2013-01-29 12:30:40 +00:00
$ $ { If } $ $ CheckBox_VLC_State == $ $ { BST_CHECKED }
2014-06-29 17:18:38 +00:00
IfFileExists " $$VLC_Directory \v lc.exe " 0 EndOfVLC
2013-01-29 12:30:40 +00:00
SetOutPath $ $ VLC_Directory \lua \intf
2013-07-19 10:32:54 +00:00
File resources \lua \intf \syncplay . lua
2014-06-29 17:18:38 +00:00
EndOfVLC :
2013-01-29 12:30:40 +00:00
$ $ { 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 "
WriteRegStr HKLM " Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ Syncplay " " VLCInstallLocation " " $$VLC_Directory "
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 ' ,
' PySide2.QtUiTools.pyd ' , ' PySide2.QtWebChannel.pyd ' , ' PySide2.QtWebSockets.pyd ' ,
' 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 ' ,
' Qt5Svg.dll ' , ' Qt5Test.dll ' , ' Qt5TextToSpeech.dll ' , ' Qt5WebChannel.dll ' , ' Qt5WebSockets.dll ' , ' Qt5WinExtras.dll ' ,
' Qt5Xml.dll ' , ' Qt5XmlPatterns.dll ' ]
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
2018-07-23 21:08:44 +00:00
guiIcons = [
' resources/accept.png ' , ' resources/arrow_undo.png ' , ' resources/clock_go.png ' ,
' resources/control_pause_blue.png ' , ' resources/cross.png ' , ' resources/door_in.png ' ,
' resources/folder_explore.png ' , ' resources/help.png ' , ' resources/table_refresh.png ' ,
' resources/timeline_marker.png ' , ' resources/control_play_blue.png ' ,
' resources/mpc-hc.png ' , ' resources/mpc-hc64.png ' , ' resources/mplayer.png ' ,
' resources/mpc-be.png ' ,
' resources/mpv.png ' , ' resources/vlc.png ' , ' resources/house.png ' , ' resources/film_link.png ' ,
' resources/eye.png ' , ' resources/comments.png ' , ' resources/cog_delete.png ' , ' resources/chevrons_right.png ' ,
' resources/user_key.png ' , ' resources/lock.png ' , ' resources/key_go.png ' , ' resources/page_white_key.png ' ,
' resources/tick.png ' , ' resources/lock_open.png ' , ' resources/empty_checkbox.png ' , ' resources/tick_checkbox.png ' ,
' resources/world_explore.png ' , ' resources/application_get.png ' , ' resources/cog.png ' , ' resources/arrow_switch.png ' ,
' resources/film_go.png ' , ' resources/world_go.png ' , ' resources/arrow_refresh.png ' , ' resources/bullet_right_grey.png ' ,
' resources/user_comment.png ' ,
' resources/error.png ' ,
' resources/film_folder_edit.png ' ,
' resources/film_edit.png ' ,
' resources/folder_film.png ' ,
' resources/shield_edit.png ' ,
' resources/shield_add.png ' ,
' resources/email_go.png ' ,
' 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 "
]
2013-06-08 16:57:57 +00:00
resources . extend ( guiIcons )
2013-08-07 23:04:01 +00:00
intf_resources = [ " 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 = [ {
" script " : " syncplayClient.py " ,
" icon_resources " : [ ( 1 , " resources \\ icon.ico " ) ] ,
' dest_base ' : " Syncplay " } ,
] ,
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 ,
2018-07-29 15:15:20 +00:00
' packages ' : ' PySide2 ' ,
' includes ' : ' twisted, sys, encodings, datetime, os, time, math, liburl, ast, unicodedata, _ssl ' ,
2018-07-23 21:08:44 +00:00
' excludes ' : ' venv, doctest, pdb, unittest, win32clipboard, win32file, win32pdh, win32security, win32trace, win32ui, winxpgui, win32pipe, win32process, Tkinter ' ,
' dll_excludes ' : ' msvcr71.dll, MSVCP90.dll, POWRPROF.dll ' ,
' optimize ' : 2 ,
' compressed ' : 1
}
} ,
data_files = [ ( " resources " , resources ) , ( " resources/lua/intf " , intf_resources ) ] ,
zipfile = " lib/libsync " ,
cmdclass = { " py2exe " : build_installer } ,
2012-10-12 16:37:12 +00:00
)
2018-07-29 15:15:20 +00:00
sys . argv . extend ( [ ' py2exe ' , ' -p win32com ' , ' -i twisted.web.resource ' , ' -p PySide2 ' ] )
setup ( * * info )