Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Tools/HeatDownloader/setup-windows.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -33,25 +33,25 @@ 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"
for %%F in ("!PYTHON_EXE!") do (
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="
Expand All @@ -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
Expand Down
29 changes: 23 additions & 6 deletions Tools/HeatDownloader/setup-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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' ---
Expand Down Expand Up @@ -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")
}
12 changes: 10 additions & 2 deletions Tools/HeatDownloader/setup.py
Original file line number Diff line number Diff line change
@@ -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(),
Expand Down
Loading