Skip to content

Commit

Permalink
Starting new installer
Browse files Browse the repository at this point in the history
  • Loading branch information
dkratzert committed Sep 1, 2023
1 parent 5f50824 commit 4624d82
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 12 deletions.
62 changes: 62 additions & 0 deletions scripts/create_dist.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
@echo off

REM This script builds a working Python environment into ..\dist of the current file location.

REM Set the Python version here:
set PYTHON_VERSION=3.11.5

set PYTHON_URL=https://www.python.org/ftp/python/%PYTHON_VERSION%/python-%PYTHON_VERSION%-embed-amd64.zip

for %%A in ("%~dp0.") do set "SCRIPT_DIR=%%~fA"
set BUILD_DIR=%SCRIPT_DIR%\..\dist
set PACKAGE_DIR=%BUILD_DIR%\python_dist


setlocal enabledelayedexpansion
for %%a in (!PYTHON_VERSION!) do (
set "NEW_PYTHON_VERSION=%%~na"
)
set "SHORT_PYTHON_VERSION=!NEW_PYTHON_VERSION:.=!"

mkdir %BUILD_DIR%
cd %BUILD_DIR%

curl %PYTHON_URL% -o python-%PYTHON_VERSION%.zip

del /S /Q /F %PACKAGE_DIR%\*.* >NUL
rmdir /s /q %PACKAGE_DIR%
dir "%PACKAGE_DIR%" | findstr /v "\<.*\>"
if not errorlevel 1 (
echo Directory is not empty.
exit /b
) else (
echo Package dir is empty
)
mkdir %PACKAGE_DIR%

tar -xf python-%PYTHON_VERSION%.zip -C %PACKAGE_DIR%
del python-%PYTHON_VERSION%.zip

echo python%SHORT_PYTHON_VERSION%.zip > %PACKAGE_DIR%\python%SHORT_PYTHON_VERSION%._pth
echo . >> %PACKAGE_DIR%\python%SHORT_PYTHON_VERSION%._pth
echo import site >> %PACKAGE_DIR%\python%SHORT_PYTHON_VERSION%._pth
endlocal

del vc_redist.x64.exe

curl -L https://aka.ms/vs/17/release/vc_redist.x64.exe -o vc_redist.x64.exe
rem vc_redist.x64.exe /passive /quiet /install

cd %PACKAGE_DIR%

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
del get-pip.py

python -m pip install virtualenv
python -m virtualenv venv --clear --no-periodic-update
call venv\Scripts\activate.bat

call pip install -r %SCRIPT_DIR%\..\requirements.txt

cd %SCRIPT_DIR%\..
16 changes: 9 additions & 7 deletions scripts/make_win_release.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ REM execute me from the main directory
rmdir /S dist /Q
rmdir /S build /Q

CALL venv\Scripts\activate.bat

rem git restore *
rem git switch master
rem git pull

venv\Scripts\python.exe -m pip install pip -U
venv\Scripts\pip install -r requirements.txt -U
venv\Scripts\pip install pyinstaller -U
venv\Scripts\pip install -U pyinstaller-hooks-contrib
CALL scripts\create_dist.bat

CALL venv\Scripts\activate.bat

rem venv\Scripts\python.exe -m pip install pip -U
rem venv\Scripts\pip install -r requirements.txt -U
rem venv\Scripts\pip install pyinstaller -U
rem venv\Scripts\pip install -U pyinstaller-hooks-contrib

CALL venv\Scripts\python.exe scripts\make_win_release.py

rem git restore *
CALL venv\Scripts\deactivate.bat
37 changes: 32 additions & 5 deletions scripts/strf-install_win64.iss
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ AlwaysShowComponentsList=False
ShowComponentSizes=False
SetupIconFile="..\icons\strf.ico"
UninstallDisplayIcon={app}\{#MyAppName}.exe
;SignTool=signtool
SignTool=sign_sha256

[UninstallRun]
Expand All @@ -61,10 +60,11 @@ Name: "english"; MessagesFile: "compiler:Default.isl"
;Excludes: "*.pyc"

[Run]
Filename: "{app}\vc_redist.x64.exe"; WorkingDir: "{app}"; Parameters: "/passive /norestart"

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\structurefinder.exe"; WorkingDir: "{app}"; IconFilename: "{app}\icons\strf.ico"; Check: IsWin64
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"; IconFilename: "{app}\icons\strf.ico"
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppName}.exe"; WorkingDir: "{app}"; IconFilename: "{app}\icons\strf.ico"; Check: IsWin64

[UninstallDelete]
Type: files; Name: "{app}\*.pyc"
Expand All @@ -77,12 +77,39 @@ Type: filesandordirs; Name: "{app}\*"
[Tasks]

[Files]
Source: "..\dist\{#MyAppName}\*"; DestDir: "{app}"; Flags: ignoreversion createallsubdirs recursesubdirs
Source: "{#MyAppName}-crash.txt"; DestDir: "{app}"; Permissions: everyone-full
Source: "..\src\structurefinder\*"; DestDir: "{app}\structurefinder"; Flags: ignoreversion createallsubdirs recursesubdirs
Source: "..\dist\python_dist\*"; DestDir: "{app}"; Flags: ignoreversion createallsubdirs recursesubdirs
Source: "..\icons\*"; DestDir: "{app}"; Flags: ignoreversion createallsubdirs recursesubdirs
Source: "..\structurefinder.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\structurefinder.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\vc_redist.x64.exe"; DestDir: "{app}"; Flags: ignoreversion

[Dirs]
Name: "{app}\displaymol"; Permissions: everyone-full
Name: "{app}\gui"; Permissions: everyone-full

[Code]
procedure CurStepChanged(CurStep: TSetupStep);
// This procedure deletes the installer executable when it
// is named 'update-structurefinder.exe'
var
strContent: String;
intErrorCode: Integer;
strSelf_Delete_BAT: String;
begin
// Pos == str.contains(x)
if Pos('update-structurefinder.exe', ExpandConstant('{srcexe}')) > 0 then
begin
if CurStep=ssDone then
begin
strContent := ':try_delete' + #13 + #10 +
'del "' + ExpandConstant('{srcexe}') + '"' + #13 + #10 +
'if exist "' + ExpandConstant('{srcexe}') + '" goto try_delete' + #13 + #10 +
'del %0';
strSelf_Delete_BAT := ExtractFilePath(ExpandConstant('{tmp}')) + 'SelfDelete.bat';
SaveStringToFile(strSelf_Delete_BAT, strContent, False);
Exec(strSelf_Delete_BAT, '', '', SW_HIDE, ewNoWait, intErrorCode);
end;
end;
end;

0 comments on commit 4624d82

Please sign in to comment.