Skip to content

Commit

Permalink
541 windows installer error (computational-cell-analytics#593)
Browse files Browse the repository at this point in the history
Fix windows installer
  • Loading branch information
lufre1 authored May 13, 2024
1 parent e3b6ad6 commit fab3249
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build_installers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
RUN_SCRIPT: |
python version_getter.py
mkdir ./${{ matrix.os }}_x86_64
constructor --output-dir ./${{ matrix.os }}_x86_64 .
constructor --output-dir ./${{ matrix.os }}_x86_64 --config-filename construct_${{ matrix.os }}.yaml .
steps:
- name: checkout
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions deployment/construct_windows-latest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: micro_sam
version: 0.0.1
license_file: ../LICENSE
installer_type: pkg #[osx] # This will trigger pkg build on Mac Os. On windows and linux, native build will be done and this has no effect.
environment: __MICROSAM_BUILD_ENV__
welcome_image: ../doc/logo/logo.png
header_image: ../doc/logo/logo.png
icon_image: ../doc/logo/logo.png
channels:
- conda-forge
welcome_text: Install Segment Anything for Microscopy.
conclusion_text: Segment Anything for Microscopy has been installed.
initialize_by_default: false
post_install: post_install.bat
49 changes: 49 additions & 0 deletions deployment/post_install.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@echo off

rem This script searches for the 'freetype.dll' file within a specific directory
rem and attempts to move it to the target directory during post-installation on Windows.
rem If not found locally, it downloads the DLL from a defined URL.


rem Define download URL (replace with the actual URL for your desired version)
set DOWNLOAD_URL=https://raw.githubusercontent.com/ubawurinna/freetype-windows-binaries/master/release%20dll/win64/freetype.dll

rem Define target directory within the installation prefix
set TARGET_DIR=%PREFIX%\Scripts

rem Create the target directory if it doesn't exist
if not exist "%TARGET_DIR%" mkdir "%TARGET_DIR%"

rem Search for freetype.dll in specific directory (adjust path as needed)
for /F "tokens=*" %%a in ('dir /S /B "%PREFIX%\Library\freetype.dll"') do (
if exist "%%a" (
echo Found freetype.dll in %%a
move "%%a" "%TARGET_DIR%"
if exist "%TARGET_DIR%\freetype.dll" (
echo Moved freetype.dll to %TARGET_DIR%
exit /b 0 ; Exit script with success code if moved
) else (
echo Error: Failed to move freetype.dll (check permissions)
exit /b 1 ; Exit script with error code
)
)
)

rem If not found in specific location, proceed with download
powershell -ExecutionPolicy Bypass -Command Invoke-WebRequest -Uri %DOWNLOAD_URL% -OutFile "%TARGET_DIR%\freetype.dll"

if exist "%TARGET_DIR%\freetype.dll" (
echo Downloaded freetype.dll to %TARGET_DIR%
) else (
echo Error downloading freetype.dll
rem Attempt to download the DLL again (optional)
powershell -ExecutionPolicy Bypass -Command Invoke-WebRequest -Uri %DOWNLOAD_URL% -OutFile "%TARGET_DIR%\freetype.dll"
if exist "%TARGET_DIR%\freetype.dll" (
echo Retry: Downloaded freetype.dll to %TARGET_DIR%
) else (
echo Error: Failed to download freetype.dll even after retry
exit /b 1 ; Exit script with error code after retries
)
)

exit /b 0 ; Exit script with success code (after download if necessary)

0 comments on commit fab3249

Please sign in to comment.