diff --git a/.gitignore b/.gitignore index ec8869d..8415b02 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ __pycache__ -/.venv +.venv /*.build /*.dist /htdemucs_ft diff --git a/scripts/windows/refresh_env.bat b/scripts/windows/refresh_env.bat new file mode 100644 index 0000000..a551f52 --- /dev/null +++ b/scripts/windows/refresh_env.bat @@ -0,0 +1,68 @@ +:: +:: RefreshEnv.cmd +:: +:: Batch file to read environment variables from registry and +:: set session variables to these values. +:: +:: With this batch file, there should be no need to reload command +:: environment every time you want environment changes to propagate + +::echo "RefreshEnv.cmd only works from cmd.exe, please install the Chocolatey Profile to take advantage of refreshenv from PowerShell" +echo | set /p dummy="Refreshing environment variables from registry for cmd.exe. Please wait..." + +@echo off + +goto main + +:: Set one environment variable from registry key +:SetFromReg + "%WinDir%\System32\Reg" QUERY "%~1" /v "%~2" > "%TEMP%\_envset.tmp" 2>NUL + for /f "usebackq skip=2 tokens=2,*" %%A IN ("%TEMP%\_envset.tmp") do ( + echo/set "%~3=%%B" + ) + goto :EOF + +:: Get a list of environment variables from registry +:GetRegEnv + "%WinDir%\System32\Reg" QUERY "%~1" > "%TEMP%\_envget.tmp" + for /f "usebackq skip=2" %%A IN ("%TEMP%\_envget.tmp") do ( + if /I not "%%~A"=="Path" ( + call :SetFromReg "%~1" "%%~A" "%%~A" + ) + ) + goto :EOF + +:main + echo/@echo off >"%TEMP%\_env.cmd" + + :: Slowly generating final file + call :GetRegEnv "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" >> "%TEMP%\_env.cmd" + call :GetRegEnv "HKCU\Environment">>"%TEMP%\_env.cmd" >> "%TEMP%\_env.cmd" + + :: Special handling for PATH - mix both User and System + call :SetFromReg "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" Path Path_HKLM >> "%TEMP%\_env.cmd" + call :SetFromReg "HKCU\Environment" Path Path_HKCU >> "%TEMP%\_env.cmd" + + :: Caution: do not insert space-chars before >> redirection sign + echo/set "Path=%%Path_HKLM%%;%%Path_HKCU%%" >> "%TEMP%\_env.cmd" + + :: Cleanup + del /f /q "%TEMP%\_envset.tmp" 2>nul + del /f /q "%TEMP%\_envget.tmp" 2>nul + + :: capture user / architecture + SET "OriginalUserName=%USERNAME%" + SET "OriginalArchitecture=%PROCESSOR_ARCHITECTURE%" + + :: Set these variables + call "%TEMP%\_env.cmd" + + :: Cleanup + del /f /q "%TEMP%\_env.cmd" 2>nul + + :: reset user / architecture + SET "USERNAME=%OriginalUserName%" + SET "PROCESSOR_ARCHITECTURE=%OriginalArchitecture%" + + echo | set /p dummy="Finished." + echo .``` \ No newline at end of file diff --git a/scripts/windows/run.bat b/scripts/windows/run.bat new file mode 100644 index 0000000..8fdcdf5 --- /dev/null +++ b/scripts/windows/run.bat @@ -0,0 +1,9 @@ +@REM @echo off + +call setup.bat + +cd ..\.. + +start /B cmd /C call .venv\Scripts\python.exe -m src.gui + +cd scripts\windows \ No newline at end of file diff --git a/scripts/windows/setup.bat b/scripts/windows/setup.bat new file mode 100644 index 0000000..01f95c6 --- /dev/null +++ b/scripts/windows/setup.bat @@ -0,0 +1,19 @@ +@echo off + +@REM Install Python using WinGet if necessary +python --version >nul 2>&1 || ( winget install -e --id Python.Python.3.10 ) + +@REM Install ffmpeg using WinGet if necessary +ffmpeg -version >nul 2>&1 || ( winget install ffmpeg ) + +@REM Refresh the environment vars so any installed commands above are active +call refresh_env.bat + +@REM Set up the venv if it needs to be +if not exist ..\..\.venv\ ( python -m venv ..\..\.venv ) + +@REM Install required scripts +..\..\.venv\Scripts\pip.exe install -r ..\..\requirements.txt + +@REM Activate the new venv +..\..\.venv\Scripts\activate.bat