5 install_path
= os
.curdir
9 exclude_dirs
= ['CVS', 'profile', '.idlerc']
10 exclude_files
= ['install.py', 'urk.desktop', 'urk.nsi', 'installer.exe', 'urk.exe']
12 nsis_outfile
="urk.exe"
13 nsis_make_exe
=["makensis"] #for non-windows systems
15 def identify_files(path
=os
.curdir
, prefix
='', sep
=os
.path
.join
):
16 #set files to a list of the files we want to install
17 print "Searching for files to install"
18 for filename
in os
.listdir(path
):
19 abs_file
= os
.path
.join(path
,filename
)
20 rel_file
= sep(prefix
,filename
)
21 if os
.path
.isfile(abs_file
) and filename
not in exclude_files
:
22 print "Marking file %s for installation" % rel_file
23 files_to_install
.append(rel_file
)
24 elif os
.path
.isdir(abs_file
) and filename
not in exclude_dirs
:
25 print "Marking directory %s for installation" % rel_file
26 dirs_to_install
.append(rel_file
)
27 identify_files(abs_file
, rel_file
, sep
)
30 #copy .py files to the destination directory
31 print "Installing files to %s" % install_path
32 for dirname
in dirs_to_install
:
33 dest
= os
.path
.join(install_path
,dirname
)
34 if os
.access(dest
,os
.X_OK
):
35 print "Found directory %s" % dest
37 print "Creating new directory %s" % dest
39 for filename
in files_to_install
:
40 source
= os
.path
.join(os
.curdir
,filename
)
41 dest
= os
.path
.join(install_path
,filename
)
42 print "Copying %s to %s" % (source
, dest
)
43 shutil
.copy(source
, dest
)
45 def nsis_generate_script():
46 filename
= os
.path
.join(install_path
,"urk.nsi")
47 print "Generating NSIS installer script %s" % filename
48 f
= file(filename
,'w')
51 ; This file was automatically generated by urk's install.py. Don't
52 ; even bother to modify it.
56 OutFile "installer.exe"
58 InstallDir $PROGRAMFILES\urk
60 InstallDirRegKey HKLM "Software\urk" "Install_Dir"
67 UninstPage uninstConfirm
72 Var /GLOBAL python_dir
73 ReadRegStr $python_dir HKLM "Software\Python\PythonCore\2.4\InstallPath" ""
77 Function GetPythonVersion
78 Var /GLOBAL python_version
80 ExecWait "$python_dir\python.exe -V"
85 Section /o "dependencies"
87 MessageBox MB_OK $python_dir
91 Section "urk (required)"
94 #look for existing installation?
95 for dirname
in dirs_to_install
:
96 f
.write(' CreateDirectory "$INSTDIR\\%s"\n' % dirname
)
97 for filename
in files_to_install
:
98 f
.write(' File "/oname=%s" "%s"\n' % (filename
, filename
))
101 WriteRegStr HKLM SOFTWARE\urk "Install_Dir" "$INSTDIR"
103 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\urk" "DisplayName" "urk IRC Client"
104 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\urk" "UninstallString" '"$INSTDIR\uninstall.exe"'
105 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\urk" "NoModify" 1
106 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\urk" "NoRepair" 1
107 WriteUninstaller "uninstall.exe"
115 ; Remove registry keys
116 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\urk"
117 DeleteRegKey HKLM SOFTWARE\urk
119 for filename
in files_to_install
:
120 f
.write(' Delete $INSTDIR\\%s\n' % filename
)
121 for dirname
in dirs_to_install
[::-1]:
122 f
.write(' RMDIR $INSTDIR\\%s\n' % dirname
)
124 Delete "$INSTDIR\uninstall.exe"
132 def nsis_generate_exe():
133 filename
= os
.path
.join(install_path
,"urk.nsi")
134 print "Calling makensis on %s" % filename
135 try: #look for NSIS in the registry
137 key_software
= _winreg
.OpenKey(_winreg
.HKEY_LOCAL_MACHINE
,"Software")
138 key_nsis
= _winreg
.OpenKey(key_software
,"NSIS")
139 make_exe
= [os
.path
.join(_winreg
.QueryValueEx(key_nsis
,None)[0],"makensis.exe")]
140 except: #..or just use the global for it
141 make_exe
= nsis_make_exe
142 subprocess
.call(make_exe
+ [filename
])
144 def install_to_nsis():
146 return '\\'.join(x
for x
in args
if x
)
147 identify_files(sep
=sep
)
148 nsis_generate_script()
151 def install_to_linux_system():