Skip to content

Commit

Permalink
windows_pacakge: Fix problem with paths containing spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
nagadomi committed Jul 24, 2024
1 parent 6d041e9 commit 0fd7efb
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 32 deletions.
2 changes: 1 addition & 1 deletion windows_package/install.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
call %~dp0\update.bat
call "%~dp0\update.bat"
4 changes: 2 additions & 2 deletions windows_package/iw3-gui.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off

call %~dp0setenv.bat
pushd %NUNIF_DIR% && start "" pythonw -m iw3.gui && popd
call "%~dp0setenv.bat"
pushd "%NUNIF_DIR%" && start "" pythonw -m iw3.gui && popd
exit /b 0
4 changes: 2 additions & 2 deletions windows_package/nunif-prompt.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off

call %~dp0setenv.bat
cd %NUNIF_DIR%
call "%~dp0setenv.bat"
cd "%NUNIF_DIR%"
call cmd
12 changes: 9 additions & 3 deletions windows_package/update-installer.bat
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
@echo off

setlocal enabledelayedexpansion
call %~dp0\setenv.bat
call "%~dp0\setenv.bat"

copy %NUNIF_DIR%\windows_package\update.bat %~dp0\update.bat
copy %NUNIF_DIR%\windows_package\setenv.bat %~dp0\setenv.bat
copy /y "%NUNIF_DIR%\windows_package\setenv.bat" "%~dp0\setenv.bat"
copy /y "%NUNIF_DIR%\windows_package\update.bat" "%~dp0\update.bat"
copy /y "%NUNIF_DIR%\windows_package\install.bat" "%~dp0\install.bat"

copy /y "%NUNIF_DIR%\windows_package\nunif-prompt.bat" "%~dp0\nunif-prompt.bat"
copy /y "%NUNIF_DIR%\windows_package\iw3-gui.bat" "%~dp0\iw3-gui.bat"
copy /y "%NUNIF_DIR%\windows_package\waifu2x-gui.bat" "%~dp0\waifu2x-gui.bat"
copy /y "%NUNIF_DIR%\windows_package\waifu2x-web.bat" "%~dp0\waifu2x-web.bat"

pause
exit /b 0
38 changes: 18 additions & 20 deletions windows_package/update.bat
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
@echo off

setlocal enabledelayedexpansion
call %~dp0\setenv.bat

call "%~dp0\setenv.bat"

@rem check to make sure the variables are available
if "%ROOT_DIR%"=="" goto :on_error
Expand All @@ -27,15 +26,15 @@ if %ERRORLEVEL% neq 0 (


@rem try nunif
if not exist %NUNIF_DIR% (
git clone https://github.com/nagadomi/nunif.git %NUNIF_DIR%
if not exist "%NUNIF_DIR%" (
git clone https://github.com/nagadomi/nunif.git "%NUNIF_DIR%"
if !ERRORLEVEL! neq 0 goto :on_error
) else (
git -C %NUNIF_DIR% pull --ff
git -C "%NUNIF_DIR%" pull --ff
if !ERRORLEVEL! neq 0 (
git -C %NUNIF_DIR% reset --hard
git -C "%NUNIF_DIR%" reset --hard
if !ERRORLEVEL! neq 0 goto :on_error
git -C %NUNIF_DIR% pull --ff
git -C "%NUNIF_DIR%" pull --ff
if !ERRORLEVEL! neq 0 goto :on_error
)
)
Expand All @@ -44,26 +43,26 @@ if not exist %NUNIF_DIR% (
echo Install Python Packages...
python -m pip install --no-cache-dir --upgrade pip
if %ERRORLEVEL% neq 0 goto :on_error
python -m pip install --no-cache-dir --upgrade -r %NUNIF_DIR%\requirements-torch.txt
python -m pip install --no-cache-dir --upgrade -r "%NUNIF_DIR%\requirements-torch.txt"
if %ERRORLEVEL% neq 0 goto :on_error
python -m pip install --no-cache-dir --upgrade -r %NUNIF_DIR%\requirements.txt
python -m pip install --no-cache-dir --upgrade -r "%NUNIF_DIR%\requirements.txt"
if %ERRORLEVEL% neq 0 goto :on_error
python -m pip install --no-cache-dir --upgrade -r %NUNIF_DIR%\requirements-gui.txt
python -m pip install --no-cache-dir --upgrade -r "%NUNIF_DIR%\requirements-gui.txt"
if %ERRORLEVEL% neq 0 goto :on_error


echo Download Models...
pushd %NUNIF_DIR% && python -m waifu2x.download_models && popd
pushd "%NUNIF_DIR%" && python -m waifu2x.download_models && popd
if %ERRORLEVEL% neq 0 goto :on_error

pushd %NUNIF_DIR% && python -m iw3.download_models && popd
pushd "%NUNIF_DIR%" && python -m iw3.download_models && popd
if %ERRORLEVEL% neq 0 goto :on_error


@rem warmup, create pyc
pushd %NUNIF_DIR% && python -m iw3.gui --help > nul && popd
pushd "%NUNIF_DIR%" && python -m iw3.gui --help > nul && popd
if %ERRORLEVEL% neq 0 goto :on_error
pushd %NUNIF_DIR% && python -m waifu2x.gui --help > nul && popd
pushd "%NUNIF_DIR%" && python -m waifu2x.gui --help > nul && popd
if %ERRORLEVEL% neq 0 goto :on_error


Expand All @@ -80,7 +79,7 @@ exit /b 0
set MINGIT_URL=https://github.com/git-for-windows/git/releases/download/v2.45.2.windows.1/MinGit-2.45.2-64-bit.zip
set TMP_DIR=%ROOT_DIR%\tmp

if not exist %TMP_DIR% mkdir %TMP_DIR%
if not exist "%TMP_DIR%" mkdir "%TMP_DIR%"

@rem Install MinGit
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
Expand All @@ -103,8 +102,7 @@ exit /b 0
set GETPIP_URL=https://bootstrap.pypa.io/get-pip.py
set PTH_PATH=%PYTHON_DIR%\python310._pth
set TMP_DIR=%ROOT_DIR%\tmp

if not exist %TMP_DIR% mkdir %TMP_DIR%
if not exist "%TMP_DIR%" mkdir "%TMP_DIR%"

@rem Install Embeddable Python
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
Expand All @@ -115,8 +113,8 @@ exit /b 0
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%

@rem setup pth file to work isolated mode
echo ..\nunif>> %PTH_PATH%
echo import site>> %PTH_PATH%
echo ..\nunif>> "%PTH_PATH%"
echo import site>> "%PTH_PATH%"

echo Successfully installed Python

Expand All @@ -127,7 +125,7 @@ exit /b 0
"Start-BitsTransfer -Source $env:GETPIP_URL -Destination $env:PYTHON_DIR\get-pip.py"
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%

python %PYTHON_DIR%\get-pip.py
python "%PYTHON_DIR%\get-pip.py"
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%

echo Successfully installed pip
Expand Down
4 changes: 2 additions & 2 deletions windows_package/waifu2x-gui.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off

call %~dp0setenv.bat
pushd %NUNIF_DIR% && start "" pythonw -m waifu2x.gui && popd
call "%~dp0setenv.bat"
pushd "%NUNIF_DIR%" && start "" pythonw -m waifu2x.gui && popd
exit /b 0
4 changes: 2 additions & 2 deletions windows_package/waifu2x-web.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@echo off

call %~dp0setenv.bat
cd %NUNIF_DIR%
call "%~dp0setenv.bat"
cd "%NUNIF_DIR%"
python -m waifu2x.web
pause

0 comments on commit 0fd7efb

Please sign in to comment.