Add windows installer generation to dist.py

This commit is contained in:
blitzmann
2014-11-29 20:49:58 -05:00
parent 9782ca3a29
commit b93b59fe4d
2 changed files with 136 additions and 4 deletions

View File

@@ -14,6 +14,7 @@ import datetime
import random
import string
import zipfile
from subprocess import call
class FileStub():
def write(self, *args):
@@ -31,7 +32,7 @@ def zipdir(path, zip):
zip.write(os.path.join(root, file))
skels = ['win', 'mac', 'src']
# todo: iscc = "C:\Program Files\Inno Setup 5\ISCC.exe" # inno script location via wine
iscc = "C:\Program Files (x86)\Inno Setup 5\ISCC.exe" # inno script location via wine
if __name__ == "__main__":
oldstd = sys.stdout
@@ -42,7 +43,7 @@ if __name__ == "__main__":
parser.add_option("-p", "--platforms", dest="platforms", help="Comma-separated list of platforms to build", default="win,src,mac")
parser.add_option("-t", "--static", dest="static", help="Directory containing static files")
parser.add_option("-q", "--quiet", dest="silent", action="store_true")
#parser.add_option("-w", "--win-exe", dest="win-exe", action="store_true", help="Build the Windows installer file (needs Inno Setup)")
parser.add_option("-w", "--winexe", dest="winexe", action="store_true", help="Build the Windows installer file (needs Inno Setup)")
parser.add_option("-z", "--zip", dest="zip", action="store_true", help="zip archive instead of tar")
options, args = parser.parse_args()
@@ -69,14 +70,17 @@ if __name__ == "__main__":
skeleton = os.path.expanduser(os.path.join(options.skeleton, skel))
info = execfile(os.path.join(skeleton, "info.py"), infoDict)
dirName = infoDict["arcname"]
nowdt = datetime.datetime.now()
now = "%04d%02d%02d" % (nowdt.year, nowdt.month, nowdt.day)
git = False
if pyfaconfig.tag.lower() == "git":
try: # if there is a git repo associated with base, use master commit
with open(os.path.join(options.base,"..",".git","refs","heads","master"), 'r') as f:
id = f.readline()[0:6]
git = True
except: # else, use custom ID
id = id_generator()
fileName = "pyfa-%s-%s" % (id, infoDict["os"])
fileName = "pyfa-%s-%s-%s" % (now, id, infoDict["os"])
else:
fileName = "pyfa-%s-%s-%s-%s" % (pyfaconfig.version, pyfaconfig.expansionName.lower(), pyfaconfig.expansionVersion, infoDict["os"])
@@ -141,6 +145,30 @@ if __name__ == "__main__":
print "Moving archive to ", destination
shutil.move(tmpFile, destination)
if "win" in skel and options.winexe:
print "Compiling EXE"
if pyfaconfig.tag.lower() == "git":
if git: # if git repo info available, use git commit
expansion = "git-%s"%(id)
else: # if there is no git repo, use timestamp
expansion = now
else: # if code is Stable, use expansion name
expansion = "%s %s"%(pyfaconfig.expansionName, pyfaconfig.expansionVersion),
calllist = ["wine"] if 'win' not in sys.platform else []
call(calllist + [
iscc,
os.path.join(os.path.dirname(__file__), "pyfa-setup.iss"),
"/dMyAppVersion=%s"%(pyfaconfig.version),
"/dMyAppExpansion=%s"%(expansion),
"/dMyAppDir=%s"%dst,
"/dMyOutputDir=%s"%destination,
"/dMyOutputFile=%s"%fileName]) #stdout=devnull, stderr=devnull
print "EXE completed"
except Exception as e:
print "Encountered an error: \n\t", e
raise

104
scripts/pyfa-setup.iss Normal file
View File

@@ -0,0 +1,104 @@
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
; Versioning
; we do some #ifdef conditionals because automated compilation passes these as arguments
#ifndef MyAppVersion
#define MyAppVersion "1.3.0"
#endif
#ifndef MyAppExpansion
#define MyAppExpansion "Crius 1.0"
#endif
; Other config
#define MyAppName "pyfa"
#define MyAppPublisher "pyfa"
#define MyAppURL "https://forums.eveonline.com/default.aspx?g=posts&t=247609&p=1"
#define MyAppExeName "pyfa.exe"
#ifndef MyOutputFile
#define MyOutputFile LowerCase(StringChange(MyAppName+'-'+MyAppVersion+'-'+MyAppExpansion+'-win', " ", "-"))
#endif
#ifndef MyAppDir
#define MyAppDir "pyfa"
#endif
#ifndef MyOutputDir
#define MyOutputDir "dist"
#endif
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{3DA39096-C08D-49CD-90E0-1D177F32C8AA}
AppName={#MyAppName}
AppVersion={#MyAppVersion} ({#MyAppExpansion})
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
LicenseFile={#MyAppDir}\gpl.txt
OutputDir={#MyOutputDir}
OutputBaseFilename={#MyOutputFile}
SetupIconFile={#MyAppDir}\pyfa.ico
Compression=lzma
SolidCompression=yes
CloseApplications=yes
AppReadmeFile=https://github.com/DarkFenX/Pyfa/blob/v{#MyAppVersion}/readme.txt
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
[Files]
Source: "{#MyAppDir}\pyfa.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MyAppDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[Code]
function IsAppRunning(const FileName : string): Boolean;
var
FSWbemLocator: Variant;
FWMIService : Variant;
FWbemObjectSet: Variant;
begin
Result := false;
FSWbemLocator := CreateOleObject('WBEMScripting.SWBEMLocator');
FWMIService := FSWbemLocator.ConnectServer('', 'root\CIMV2', '', '');
FWbemObjectSet := FWMIService.ExecQuery(Format('SELECT Name FROM Win32_Process Where Name="%s"',[FileName]));
Result := (FWbemObjectSet.Count > 0);
FWbemObjectSet := Unassigned;
FWMIService := Unassigned;
FSWbemLocator := Unassigned;
end;
function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
if(IsAppRunning( 'pyfa.exe' )) then
begin
Result := 'Please close pyfa before continuing. When closed, please go back to the previous step and continue.';
end
else
begin
Result := '';
end
end;