From d2ad5bac4956d09c0a745f8507f151dbba5a7b96 Mon Sep 17 00:00:00 2001 From: Luca Di Leo Date: Wed, 29 Mar 2023 16:18:11 +0200 Subject: [PATCH 1/8] Added vcpkg venv python38 dist and innosetup folders to gitignore --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index 2bf60d58..9c06b143 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,10 @@ settings.yaml __pycache__ *.snap storage/ + + +vcpkg/ +venv/ +python38/ +dist/ +innosetup/ \ No newline at end of file From 3942755b101a19b0477b34c2bd0c429636ef077e Mon Sep 17 00:00:00 2001 From: Luca Di Leo Date: Wed, 29 Mar 2023 16:18:34 +0200 Subject: [PATCH 2/8] Innosetup now uses short paths when spaces are present --- innosetup.iss | 71 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 3 deletions(-) diff --git a/innosetup.iss b/innosetup.iss index 8ba5ab9e..a409439d 100644 --- a/innosetup.iss +++ b/innosetup.iss @@ -70,18 +70,83 @@ Filename: "{tmp}\vc_redist.x64.exe"; StatusMsg: "Installing Visual C++ Redistrib Filename: "{app}\console.bat"; Description: {cm:LaunchProgram,ODM Console}; Flags: nowait postinstall skipifsilent [Code] + +function GetShortPath(const LongPath: string): string; +var + ResultCode: Integer; + TmpFileName: string; + ExecStdout: AnsiString; + Parameters: string; +begin + + // Create LongPath folder + if not ForceDirectories(LongPath) then begin + Result := LongPath; + Exit; + end; + + TmpFileName := ExpandConstant('{tmp}') + '\short_result.txt'; + Parameters := '-Command "(New-Object -ComObject Scripting.FileSystemObject).GetFolder(''' + LongPath + ''').ShortPath | Out-File -FilePath ''' + TmpFileName + ''' -Encoding ASCII"'; + + // Execute the PowerShell command and save the output to the TmpFileName + if Exec('powershell.exe', Parameters, '', 0, ewWaitUntilTerminated, ResultCode) then + begin + // Read the output from the TmpFileName + if LoadStringFromFile(TmpFileName, ExecStdout) then begin + Result := Trim(ExecStdout); + end + else begin + Result := LongPath; + end; + + DeleteFile(TmpFileName); + // Delete the folder + if not RemoveDir(LongPath) then begin + Result := LongPath; + Exit; + end; + + end + else + begin + Result := LongPath; + end; +end; + + +function NextButtonClick(CurPageID: Integer): Boolean; +var + Dir: string; +begin + if CurPageID = wpSelectDir then + begin + // Get the selected directory + Dir := WizardForm.DirEdit.Text; + + // Check if the path contains spaces + if Pos(' ', Dir) > 0 then + begin + // Get the short path name + Dir := GetShortPath(Dir); + // Set the selected directory to the short path name + WizardForm.DirEdit.Text := Dir; + end; + end; + Result := True; +end; + function VC2019RedistNeedsInstall: Boolean; -var +var Version: String; begin if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64', 'Version', Version) then begin - // Is the installed version at least 14.14 ? + // Is the installed version at least 14.14 ? Log('VC Redist Version check : found ' + Version); Result := (CompareStr(Version, 'v14.14.26429.03')<0); end - else + else begin // Not even an old version installed Result := True; From d01353927592c1b0a629ce152f1dbc888c6bf164 Mon Sep 17 00:00:00 2001 From: Luca Di Leo Date: Wed, 29 Mar 2023 19:05:21 +0200 Subject: [PATCH 3/8] Merged Python38 folder with venv\Scripts --- innosetup.iss | 66 +-------------------------------------------------- 1 file changed, 1 insertion(+), 65 deletions(-) diff --git a/innosetup.iss b/innosetup.iss index a409439d..e1d2f377 100644 --- a/innosetup.iss +++ b/innosetup.iss @@ -47,7 +47,7 @@ Source: "stages\*"; DestDir: "{app}\stages"; Excludes: "__pycache__"; Flags: ign Source: "SuperBuild\install\bin\*"; DestDir: "{app}\SuperBuild\install\bin"; Excludes: "__pycache__"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "SuperBuild\install\lib\python3.8\*"; DestDir: "{app}\SuperBuild\install\lib\python3.8"; Excludes: "__pycache__"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "venv\*"; DestDir: "{app}\venv"; Excludes: "__pycache__,pyvenv.cfg"; Flags: ignoreversion recursesubdirs createallsubdirs -Source: "python38\*"; DestDir: "{app}\python38"; Excludes: "__pycache__"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "python38\*"; DestDir: "{app}\venv\Scripts"; Excludes: "__pycache__"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "console.bat"; DestDir: "{app}"; Flags: ignoreversion Source: "VERSION"; DestDir: "{app}"; Flags: ignoreversion Source: "LICENSE"; DestDir: "{app}"; Flags: ignoreversion @@ -71,70 +71,6 @@ Filename: "{app}\console.bat"; Description: {cm:LaunchProgram,ODM Console}; Flag [Code] -function GetShortPath(const LongPath: string): string; -var - ResultCode: Integer; - TmpFileName: string; - ExecStdout: AnsiString; - Parameters: string; -begin - - // Create LongPath folder - if not ForceDirectories(LongPath) then begin - Result := LongPath; - Exit; - end; - - TmpFileName := ExpandConstant('{tmp}') + '\short_result.txt'; - Parameters := '-Command "(New-Object -ComObject Scripting.FileSystemObject).GetFolder(''' + LongPath + ''').ShortPath | Out-File -FilePath ''' + TmpFileName + ''' -Encoding ASCII"'; - - // Execute the PowerShell command and save the output to the TmpFileName - if Exec('powershell.exe', Parameters, '', 0, ewWaitUntilTerminated, ResultCode) then - begin - // Read the output from the TmpFileName - if LoadStringFromFile(TmpFileName, ExecStdout) then begin - Result := Trim(ExecStdout); - end - else begin - Result := LongPath; - end; - - DeleteFile(TmpFileName); - // Delete the folder - if not RemoveDir(LongPath) then begin - Result := LongPath; - Exit; - end; - - end - else - begin - Result := LongPath; - end; -end; - - -function NextButtonClick(CurPageID: Integer): Boolean; -var - Dir: string; -begin - if CurPageID = wpSelectDir then - begin - // Get the selected directory - Dir := WizardForm.DirEdit.Text; - - // Check if the path contains spaces - if Pos(' ', Dir) > 0 then - begin - // Get the short path name - Dir := GetShortPath(Dir); - // Set the selected directory to the short path name - WizardForm.DirEdit.Text := Dir; - end; - end; - Result := True; -end; - function VC2019RedistNeedsInstall: Boolean; var Version: String; From f89ddfb1bd2193ee641a4f0c26b9529ae8134079 Mon Sep 17 00:00:00 2001 From: Luca Di Leo Date: Wed, 29 Mar 2023 19:05:40 +0200 Subject: [PATCH 4/8] Fixed pyenv home path --- win32env.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win32env.bat b/win32env.bat index 36c35d17..8428b1b3 100644 --- a/win32env.bat +++ b/win32env.bat @@ -24,7 +24,7 @@ set PYTHONPATH=%VIRTUAL_ENV% set PYENVCFG=%VIRTUAL_ENV%\pyvenv.cfg rem Hot-patching pyvenv.cfg -echo home = %ODMBASE%\python38> "%PYENVCFG%" +echo home = %ODMBASE%venv\Scripts> "%PYENVCFG%" echo include-system-site-packages = false>> "%PYENVCFG%" rem Hot-patching cv2 extension configs From c4874df8cb4ef66270ef9ac58f72d5baa450e522 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Thu, 30 Mar 2023 16:04:20 -0400 Subject: [PATCH 5/8] upload setup artifact during Windows test build --- .github/workflows/test-build-prs.yaml | 29 +++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-build-prs.yaml b/.github/workflows/test-build-prs.yaml index caab9530..5f6257ae 100644 --- a/.github/workflows/test-build-prs.yaml +++ b/.github/workflows/test-build-prs.yaml @@ -58,17 +58,38 @@ jobs: with: python-version: '3.8.1' architecture: 'x64' + - uses: Jimver/cuda-toolkit@v0.2.4 + id: cuda-toolkit + with: + cuda: '11.4.0' - name: Setup cmake uses: jwlawson/actions-setup-cmake@v1.13 with: cmake-version: '3.24.x' - - name: Setup Visual C++ - uses: ilammy/msvc-dev-cmd@v1 + - name: Extract code signing cert + id: code_sign + uses: timheuer/base64-to-file@v1 with: - arch: x64 + fileName: 'comodo.pfx' + encodedString: ${{ secrets.CODE_SIGNING_CERT }} - name: Install venv run: | python -m pip install virtualenv - name: Build sources run: | - python configure.py build \ No newline at end of file + python configure.py build + - name: Free up space + run: | + rmdir SuperBuild\download /s /q + rmdir SuperBuild\build /s /q + shell: cmd + - name: Create setup + env: + CODE_SIGN_CERT_PATH: ${{ steps.code_sign.outputs.filePath }} + run: | + python configure.py dist --code-sign-cert-path $env:CODE_SIGN_CERT_PATH + - name: Upload Setup File + uses: actions/upload-artifact@v2 + with: + name: Setup + path: dist\*.exe From f60dc33df01541b23ac02e206d14e4ca725c7683 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Fri, 31 Mar 2023 12:10:51 -0400 Subject: [PATCH 6/8] Test build installer without signing cert --- .github/workflows/test-build-prs.yaml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/test-build-prs.yaml b/.github/workflows/test-build-prs.yaml index 5f6257ae..092c3446 100644 --- a/.github/workflows/test-build-prs.yaml +++ b/.github/workflows/test-build-prs.yaml @@ -66,12 +66,6 @@ jobs: uses: jwlawson/actions-setup-cmake@v1.13 with: cmake-version: '3.24.x' - - name: Extract code signing cert - id: code_sign - uses: timheuer/base64-to-file@v1 - with: - fileName: 'comodo.pfx' - encodedString: ${{ secrets.CODE_SIGNING_CERT }} - name: Install venv run: | python -m pip install virtualenv @@ -84,10 +78,8 @@ jobs: rmdir SuperBuild\build /s /q shell: cmd - name: Create setup - env: - CODE_SIGN_CERT_PATH: ${{ steps.code_sign.outputs.filePath }} run: | - python configure.py dist --code-sign-cert-path $env:CODE_SIGN_CERT_PATH + python configure.py dist - name: Upload Setup File uses: actions/upload-artifact@v2 with: From 51feb49d0939e7c9670caa09d0ffc62ed263edfe Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Fri, 31 Mar 2023 17:06:07 -0400 Subject: [PATCH 7/8] Fix signtool path --- configure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.py b/configure.py index 7b722b4b..d5caf615 100644 --- a/configure.py +++ b/configure.py @@ -193,7 +193,7 @@ def dist(): z.extractall("innosetup") # Run - cs_flags = "" + cs_flags = '"/Ssigntool=%s"' % signtool_path if args.code_sign_cert_path: cs_flags = '"/Ssigntool=%s sign /f %s /fd SHA1 /t http://timestamp.sectigo.com $f"' % (signtool_path, args.code_sign_cert_path) run("innosetup\\iscc /Qp " + cs_flags + " \"innosetup.iss\"") From 41020ef1a84f15dd4522b7d3ce5473909b3685e5 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Sat, 1 Apr 2023 12:09:16 -0400 Subject: [PATCH 8/8] Conditional signing macro --- configure.py | 2 +- innosetup.iss | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.py b/configure.py index d5caf615..c1526046 100644 --- a/configure.py +++ b/configure.py @@ -193,7 +193,7 @@ def dist(): z.extractall("innosetup") # Run - cs_flags = '"/Ssigntool=%s"' % signtool_path + cs_flags = '/DSKIP_SIGN=1' if args.code_sign_cert_path: cs_flags = '"/Ssigntool=%s sign /f %s /fd SHA1 /t http://timestamp.sectigo.com $f"' % (signtool_path, args.code_sign_cert_path) run("innosetup\\iscc /Qp " + cs_flags + " \"innosetup.iss\"") diff --git a/innosetup.iss b/innosetup.iss index e1d2f377..799876ad 100644 --- a/innosetup.iss +++ b/innosetup.iss @@ -30,7 +30,9 @@ Compression=lzma SolidCompression=yes ArchitecturesAllowed=x64 ArchitecturesInstallIn64BitMode=x64 +#ifndef SKIP_SIGN SignTool=signtool +#endif PrivilegesRequired=lowest PrivilegesRequiredOverridesAllowed=commandline UsePreviousAppDir=no