diff --git a/Tools/HeatDownloader/setup-windows.cmd b/Tools/HeatDownloader/setup-windows.cmd index 931bd6d..2afff9d 100644 --- a/Tools/HeatDownloader/setup-windows.cmd +++ b/Tools/HeatDownloader/setup-windows.cmd @@ -20,10 +20,10 @@ for /f "delims=" %%i in ('where python py 2^>nul') do ( ) :found_python_exe if not defined PYTHON ( - call :echo_err Python not found in PATH. Please install Python 3.6 or later. + call :echo_err "Python not found in PATH. Please install Python 3.6 or later." exit /b 1 ) -echo Found Python executable at: !PYTHON! +echo "Found Python executable at: !PYTHON!" REM === Use the pip module as the PIP command === if %pip_exists% NEQ 0 ( @@ -33,14 +33,14 @@ if %pip_exists% NEQ 0 ( REM === Check if PYTHON points to the windows python launcher and set PYTHON_PATH === !PYTHON! -0p >nul 2>&1 if !errorlevel! NEQ 0 ( - echo No python launcher found. + echo "No python launcher found." for %%I in ("!PYTHON!") do ( set "PYTHON_PATH=%%~dpI" if "!PYTHON_PATH:~-1!"=="\" set "PYTHON_PATH=!PYTHON_PATH:~0,-1!" ) ) else ( REM === Resolve the actual python executable path (active python) === - echo Found Windows Python launcher + echo "Found Windows Python launcher" for /f "delims=" %%i in ('py -0p 2^>nul') do ( for /f "tokens=3*" %%a in ("%%i") do ( set "PYTHON_EXE=%%a %%b" @@ -48,10 +48,10 @@ if !errorlevel! NEQ 0 ( set "PYTHON_PATH=%%~dpF" if "!PYTHON_PATH:~-1!"=="\" set "PYTHON_PATH=!PYTHON_PATH:~0,-1!" ) - echo Python version found: %%a at !PYTHON_PATH! + echo "Python version found: %%a at !PYTHON_PATH!" !PYTHON! -h | findstr /C:"!PYTHON_PATH!" >nul 2>&1 if !errorlevel! EQU 0 ( - echo Active python path: !PYTHON_PATH! + echo "Active python path: !PYTHON_PATH!" goto :check_python ) else ( set "PYTHON_PATH=" @@ -63,7 +63,7 @@ if !errorlevel! NEQ 0 ( :check_python if not defined PYTHON_PATH ( - call :echo_err Failed to determine Python path. + call :echo_err "Failed to determine Python path." exit /b 1 ) !PYTHON! --version | findstr /R "^Python 3\.[0-9]*" >nul 2>&1 diff --git a/Tools/HeatDownloader/setup-windows.ps1 b/Tools/HeatDownloader/setup-windows.ps1 index a67aa3f..4b4e431 100644 --- a/Tools/HeatDownloader/setup-windows.ps1 +++ b/Tools/HeatDownloader/setup-windows.ps1 @@ -85,19 +85,36 @@ if (-not (Test-Path $scriptsDir)) { } # Helper to invoke pip -function Invoke-Pip([string[]]$Arguments) { - & $pipExec @($pipArgs + $Arguments) +function Invoke-Pip { + param ( + [Parameter(Mandatory=$true)] + [string[]]$Arguments + ) + try { + $process = Start-Process -FilePath $pipExec ` + -ArgumentList @($pipArgs + $Arguments) ` + -NoNewWindow -Wait ` + -PassThru ` + + if ($process.ExitCode -ne 0) { + throw "pip failed with exit code $($process.ExitCode). Check logs." + } + } + catch { + throw + } } # --- 5) Install the package in editable mode --- try { - Write-Host "==========| Installing package in editable mode |==========" + Write-Host ("==========| Installing package in editable mode |==========") Invoke-Pip -Arguments 'install','-e','.','--force-reinstall' - Write-Host ("="*40) Write-Ok "Installation attempt finished." } catch { Write-Err "Failed to install the package: $_" exit 1 +} finally { + Write-Host ("="*50) } # --- 6) Verify installation via 'pip show' --- @@ -136,6 +153,6 @@ Write-Ok "`nPackage installed successfully! You can now use 'heat-downloader'." if ($pathOk) { Write-Ok "Just run: heat-downloader --help" } else { - Write-Warn ("Since Scripts is not in PATH, run directly: `"$scriptFullPath`" - Or as a module: `"$pythonExe -m heat_downloader --help") + Write-Warn ( "Since Scripts is not in PATH, run directly: `"$scriptFullPath`" ` +Or as a module: `"$pythonExe -m heat_downloader --help") } \ No newline at end of file diff --git a/Tools/HeatDownloader/setup.py b/Tools/HeatDownloader/setup.py index 3a27a00..c99a4c7 100644 --- a/Tools/HeatDownloader/setup.py +++ b/Tools/HeatDownloader/setup.py @@ -1,11 +1,19 @@ from setuptools import setup, find_packages from pathlib import Path -from heat_downloader import __version__ +# TODO: fix this crap later +def read_version(): + version_file = Path('heat_downloader/__init__.py').read_text() + for line in version_file.splitlines(): + if line.startswith('__version__'): + delim = '"' if '"' in line else "'" + return line.split(delim)[1] + raise RuntimeError("Unable to find version string.") + setup( name = 'heat-downloader', - version = __version__, + version = read_version(), description = 'A tool to download the latest Heat releases', author = 'Yossi99', packages = find_packages(),