Skip to content

Commit f95a6b4

Browse files
Added installer
1 parent 3db150a commit f95a6b4

File tree

4 files changed

+124
-1
lines changed

4 files changed

+124
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ Release/
66
*.sdf
77
*.pyo
88
*.pyc
9-
*.dll
9+
*.dll
10+
/installer/*.exe
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import sys
2+
import _win32sysloader
3+
import os
4+
5+
# Anaconda and possibly other distributions have a bug in PyWin32,
6+
# the `pythoncom` module can't be loaded because some required
7+
# DLLs are located in the wrong place, so they aren't found
8+
9+
# force windows to load them with the full path so that subsequent
10+
# imports work correctly
11+
12+
filename = "pywintypes%d%d.dll" % (sys.version_info[0], sys.version_info[1])
13+
14+
found = _win32sysloader.GetModuleFilename(filename)
15+
16+
if not found:
17+
found = _win32sysloader.LoadModule(os.path.join(sys.prefix, 'lib', 'site-packages', 'win32', filename))
18+
19+
20+
21+

addin/xlpython/xlpyserver.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
import fix_anaconda_pywin32
23
import types
34
import pythoncom
45
import pywintypes

installer/setup.iss

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
; Script generated by the Inno Setup Script Wizard.
2+
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
3+
4+
#define MyAppName "ExcelPython"
5+
#define MyAppVersion "2.0.6"
6+
#define MyAppPublisher "ericremoreynolds"
7+
#define MyAppURL "https://github.com/ericremoreynolds/excelpython"
8+
9+
[Setup]
10+
; NOTE: The value of AppId uniquely identifies this application.
11+
; Do not use the same AppId value in installers for other applications.
12+
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
13+
AppId={{729BFC46-B43F-4BA7-9DD2-8D42F116EE9C}
14+
AppName={#MyAppName}
15+
AppVersion={#MyAppVersion}
16+
AppPublisher={#MyAppPublisher}
17+
AppPublisherURL={#MyAppURL}
18+
AppSupportURL={#MyAppURL}
19+
AppUpdatesURL={#MyAppURL}
20+
LicenseFile=D:\github\excelpython\LICENSE
21+
OutputDir=D:\github\excelpython\installer
22+
OutputBaseFilename=excelpython-{#MyAppVersion}
23+
Compression=lzma
24+
SolidCompression=yes
25+
DefaultDirName={code:DefAppFolder}
26+
UninstallFilesDir={pf}\ExcelPython
27+
28+
DirExistsWarning=no
29+
30+
[Languages]
31+
Name: "english"; MessagesFile: "compiler:Default.isl"
32+
33+
[Dirs]
34+
Name: "{app}\xlpython"
35+
36+
[Files]
37+
Source: "..\addin\xlpython.xlam"; DestDir: "{app}"; Flags: ignoreversion
38+
Source: "..\addin\xlpython\*"; DestDir: "{app}\xlpython"; Flags: ignoreversion recursesubdirs createallsubdirs
39+
Source: IssProc.dll; DestDir: "{tmp}"; Flags: dontcopy
40+
Source: IssProc.dll; DestDir: "{pf}\ExcelPython"
41+
42+
[Code]
43+
Function DefAppFolder(Param: String): String;
44+
Begin
45+
If DirExists(ExpandConstant('{%APPDATA}\Roaming\Microsoft\Excel\XLSTART')) Then Begin
46+
Result := ExpandConstant('{%APPDATA}\Roaming\Microsoft\Excel\XLSTART');
47+
End Else Begin
48+
Result := ExpandConstant('{%APPDATA}\Microsoft\Excel\XLSTART');
49+
End;
50+
End;
51+
52+
// Windows CreateFile function
53+
function CreateFile(
54+
lpFileName : String;
55+
dwDesiredAccess : Cardinal;
56+
dwShareMode : Cardinal;
57+
lpSecurityAttributes : Cardinal;
58+
dwCreationDisposition : Cardinal;
59+
dwFlagsAndAttributes : Cardinal;
60+
hTemplateFile : Integer
61+
): THandle;
62+
#ifdef UNICODE
63+
external 'CreateFileW@kernel32.dll stdcall';
64+
#else
65+
external 'CreateFileA@kernel32.dll stdcall';
66+
#endif
67+
68+
// Windows CloseHandle function
69+
function CloseHandle(hHandle: THandle): BOOL;
70+
external 'CloseHandle@kernel32.dll stdcall';
71+
72+
Const
73+
GENERIC_WRITE = $40000000;
74+
{ FILE_ATTRIBUTE_NORMAL = $80; }
75+
OPEN_EXISTING = 3;
76+
INVALID_HANDLE_VALUE = -1;
77+
78+
// Function to check if file can be deleted
79+
Function CanDelete(FileName: String): Boolean;
80+
Var
81+
FileHandle: THandle;
82+
Begin
83+
Result := False;
84+
FileHandle := CreateFile(FileName, GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
85+
Result := (FileHandle <> INVALID_HANDLE_VALUE);
86+
If Result Then CloseHandle(FileHandle);
87+
End;
88+
89+
// Ensure that the add-in can be deleted
90+
function InitializeUninstall(): Boolean;
91+
begin
92+
Result := false;
93+
If CanDelete(ExpandConstant('{app}\xlpython.xlam')) Then Begin
94+
Result := true;
95+
End Else Begin
96+
MsgBox('ExcelPython appears to be in use - please make sure you close all instances of Excel before uninstalling.', mbError, MB_OK)
97+
Result := false;
98+
End;
99+
end;
100+

0 commit comments

Comments
 (0)