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
56 changes: 39 additions & 17 deletions Tools/HeatDownloader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,42 @@ This CLI tool allows you to download the latest build of heat. It is a simple pa
- Clone this repository in any place you like:
- Go to the `HeatDownloader` directory located in `Tools/HeatDownloader`. (Where we are now)
- Have **python 3.10** or newer
- Install the package using `pip install .`
- Install the package using `pip install -e .`
- Or use one of the installation scripts: `setup-windows.cmd` [*legacy*] or `setup-windows.ps1` [**recommended**]

### Automatic (git and script) - [_**recommended if you are naive to python**_]
#### Powershell or windows terminal:
```bash
# on powershell or windows terminal type:
git clone https://github.com/OpenYiffGames/HeatGame.git
cd HeatGame/Tools/HeatDownloader
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.\setup-windows.ps1
```
#### Legacy CMD
```bash
git clone https://github.com/OpenYiffGames/HeatGame.git
cd HeatGame/Tools/HeatDownloader
setup-windows.cmd
```

### Manual (git and pip)
```bash
# clone
git clone https://github.com/OpenYiffGames/HeatGame.git
cd HeatGame/tools/HeatDownloader
# install
pip install .
pip install -e .

# If you don't have pip try:
# python -m pip install .
# if you are on windows, your python is problably named py
# py -m pip install .
# If you don't have pip on your PATH try:
python -m pip install .
# if you are on windows, you probably have the 'windows python launcher' (py.exe)
py -m pip install .
```

## How to use it

After a succefull installation you can execute it using `python -m` command or if your enviroment is setup correctly you can just execute `heat_downloader` on your terminal.
After a successful installation you can execute it as a module with `python -m heat_downloader` or, if your environment is set up correctly, simply run `heat-downloader`. (This requires your Python Scripts directory on PATH.)

### Commands:
`-h` - shows help message \
Expand All @@ -35,28 +53,32 @@ After a succefull installation you can execute it using `python -m` command or i

### Examples:

#### Downloding
#### Downloading
```bash
# Download to directory
heat_downloader download --output my-download-directory/
# Download last version to directory
heat-downloader download --output my-download-directory/

# Download version
heat_downloader download --output my-download-directory/ --version 0.6.7.2
# Download a specific version
heat-downloader download --output my-download-directory/ --version 0.6.7.2

# If the previous options doesn't work, your path to the python's script folder is probably not set; so try this
# Running as a module
python -m heat_downloader --output my-download-directory/
```
#### List
```bash
heat_downloader list
# show all scraped versions
heat-downloader list

# limit results to last 5
heat-downloader list 5
```

## Demo
https://github.com/user-attachments/assets/0d669474-6797-41ff-bd2b-8259bcb63813

## Prebuilt binaries
If you are too lazy to install the module, you can check the [release session](https://github.com/OpenYiffGames/HeatGame/releases) where we have a single .exe packed with [PyInstaller](https://github.com/pyinstaller/pyinstaller).
Keep in mind that these binaries are auto-generated, please open an issue if you have any problems.\
If you’re too lazy to install the module, check the [releases section](https://github.com/OpenYiffGames/HeatGame/releases) for a single .exe packed with [PyInstaller](https://github.com/pyinstaller/pyinstaller).
Keep in mind these binaries are auto-generated. Please open an issue if you have any problems.

- [Lateted Version](https://github.com/OpenYiffGames/HeatGame/releases/latest/download/tools.zip)
- [Latest Version](https://github.com/OpenYiffGames/HeatGame/releases/latest/download/tools.zip)

153 changes: 153 additions & 0 deletions Tools/HeatDownloader/setup-windows.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
@echo off
setlocal enabledelayedexpansion

REM === Verify if pip exists directly ===
set PIP=pip
where /Q %PIP% >nul 2>&1
set pip_exists=%errorlevel%

REM === User confirmation ===
choice /C YN /M "This script will install the package in editable mode and WILL NOT CHECK for existing environments. Do you want to proceed?"
if errorlevel 2 exit /b 1

REM === Find the python executable ===
set "PYTHON="
for /f "delims=" %%i in ('where python py 2^>nul') do (
if exist "%%i" (
set "PYTHON=%%i"
goto :found_python_exe
)
)
:found_python_exe
if not defined PYTHON (
call :echo_err Python not found in PATH. Please install Python 3.6 or later.
exit /b 1
)
echo Found Python executable at: !PYTHON!

REM === Use the pip module as the PIP command ===
if %pip_exists% NEQ 0 (
set PIP=!PYTHON! -m pip
)

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.
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
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!
!PYTHON! -h | findstr /C:"!PYTHON_PATH!" >nul 2>&1
if !errorlevel! EQU 0 (
echo Active python path: !PYTHON_PATH!
goto :check_python
) else (
set "PYTHON_PATH="
)
)
)
)


:check_python
if not defined PYTHON_PATH (
call :echo_err Failed to determine Python path.
exit /b 1
)
!PYTHON! --version | findstr /R "^Python 3\.[0-9]*" >nul 2>&1
if errorlevel 1 (
call :echo_err "Python version is not 3.x. Please install Python 3.6 or later."
exit /b 1
)

echo Found python path: !PYTHON_PATH!

REM === Set's the SCRIPTS_PATH and verify if is exists on PATH ===
set "SCRIPTS_PATH=!PYTHON_PATH!\Scripts"
if not exist "!SCRIPTS_PATH!" (
call :echo_err "Scripts folder not found: !SCRIPTS_PATH!"
call :echo_warn "Please check if Python is installed correctly."
choice /C YN /M "Do you want to proceed anyway?"
if errorlevel 2 exit /b 1
) else (
REM Check if the scripts folder is in path
set "PATH_OK="
for %%i in ("!PATH:;=" "%") do (
if /I "%%~i"=="!SCRIPTS_PATH!" (
set "PATH_OK=1"
goto :install_package
)
)
call :echo_warn "The Scripts folder (!SCRIPTS_PATH!) is not in PATH. This may cause issues with running scripts."
call :echo_warn "Please add it to your PATH or run the script directly from the Scripts folder."
)

:install_package
REM === Install the package in editable mode ===
%PIP% install -e . --force-reinstall
if %errorlevel% neq 0 (
call :echo_err "Failed to install the package. Installation failed with error code %errorlevel%."
exit /b 1
)

REM === Verify package installation via pip ===
%PIP% show heat-downloader >nul 2>&1
if %errorlevel% neq 0 (
call :echo_err "Package not found in Python environment. Please check if the package is installed correctly."
exit /b 1
)

REM === Verify if the package scripts were installed ===
for %%i in (heat-downloader.exe heat-downloader-script.py) do (
set "script_full_path=!PYTHON_PATH!\Scripts\%%i"
if exist "!script_full_path!" (
goto :check_installation
)
)

:check_failed_fallback
call :echo_err "Package not found in Scripts folder: !script_full_path!"
call :echo_err "Please check if the package is installed correctly."
exit /b 1

:check_installation
!script_full_path! --help >nul 2>&1
if %errorlevel% neq 0 (
call :echo_err "Package is not installed correctly. Please check if environment setup is correct."
exit /b 1
)

REM === Success ===
echo.
call :echo_ok "Package installed successfully. You can now use the package."
if defined PATH_OK (
call :echo_ok "Type 'heat-downloader --help' for more information."
) else (
call :echo_warn "Since your script folder is not in PATH, you need to execute it manually from: '!script_full_path!'"
call :echo_warn "As a workaround you can execute it as a module: %PYTHON% -m heat_downloader --help"
)
exit /b 0

:echo_ok
echo %~1
goto :eof

:echo_err
echo [ERROR] %~1
goto :eof

:echo_warn
echo [WARNING] %~1
goto :eof
141 changes: 141 additions & 0 deletions Tools/HeatDownloader/setup-windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#!/usr/bin/env pwsh
# To run: open PowerShell, navigate to your project directory and execute: .\install-editable.ps1

# Stop the script on any unhandled error
$ErrorActionPreference = 'Stop'

function Write-Ok { param($msg) Write-Host $msg -ForegroundColor Green }
function Write-Err { param($msg) Write-Host "[ERROR] $msg" -ForegroundColor Red }
function Write-Warn { param($msg) Write-Host "[WARNING] $msg" -ForegroundColor Yellow }
function Stop-Operation {
Write-Err "Operation cancelled by user."
exit 2
}

# --- 1) User confirmation ---
$choices = @(
[System.Management.Automation.Host.ChoiceDescription]::new("&Yes", "Proceed with the installation."),
[System.Management.Automation.Host.ChoiceDescription]::new("&No", "Cancel the operation.")
)
$caption = "Confirmation"
$message = "This script will install the package in editable mode and WILL NOT CHECK for existing environments. Do you want to proceed?"
$result = $host.ui.PromptForChoice($caption, $message, $choices, 1)
if ($result -ne 0) {
Stop-Operation
}

# --- 2) Locate Python executable ---
# Try 'python' first, then fallback to 'py'
$pythonExe = $null
foreach ($cand in @("python","py")) {
$cmd = Get-Command $cand -ErrorAction SilentlyContinue
if ($cmd) { $pythonExe = $cmd.Source; break }
}
if (-not $pythonExe) {
Write-Err "Python executable not found in path. Please install Python 3.6 or later."
exit 1
}
$pythonVersion = & $pythonExe --version 2>&1
if ($pythonVersion -notmatch 'Python 3\.\d+') {
Write-Err "Python version is not 3.x. Please install Python 3.6 or later."
exit 1
}
Write-Ok "Found $pythonVersion at: $pythonExe"

# --- 3) Determine PIP command ---
$pipCmd = Get-Command pip -ErrorAction SilentlyContinue
if ($pipCmd) {
# Use pip directly
$pipExec = $pipCmd.Path
$pipArgs = @()
} else {
# Fallback to python -m pip
$pipExec = $pythonExe
$pipArgs = '-m','pip'
}
Write-Host "Using PIP: $pipExec $($pipArgs -join ' ')"

# --- Find python base directory ---
$pythonDir = & $pythonExe -c "import sys; sys.stdout.write(sys.base_prefix)"
if (-not (Test-Path $pythonDir)) {
Write-Err "Failed to determine Python base directory."
exit 1
}

# --- 4) Find Python's Scripts folder ---
$scriptsDir = Join-Path $pythonDir 'Scripts'
Write-Host "Checking for Scripts folder at: $scriptsDir"

if (-not (Test-Path $scriptsDir)) {
Write-Err "Scripts folder not found: $scriptsDir"
Write-Warn "Please verify that Python is installed correctly."
$answer = Read-Host "Do you want to proceed anyway? [Y/N]"
if ($answer -notmatch '^[Yy]$') {
Stop-Operation
}
} else {
# Check if Scripts folder is in the PATH
$inPath = $env:PATH.Split(';') | Where-Object { $_ -eq $scriptsDir }
if ($inPath) {
$pathOk = $true
} else {
Write-Warn "The Scripts folder ($scriptsDir) is NOT in your PATH. This may cause execution issues."
Write-Warn "Consider adding it to the PATH or running scripts directly from this folder."
}
}

# Helper to invoke pip
function Invoke-Pip([string[]]$Arguments) {
& $pipExec @($pipArgs + $Arguments)
}

# --- 5) Install the package in editable mode ---
try {
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
}

# --- 6) Verify installation via 'pip show' ---
try {
Invoke-Pip -Arguments 'show','heat-downloader' | Out-Null
} catch {
Write-Err "Package 'heat-downloader' not found in the Python environment."
exit 1
}

# --- 7) Check for generated executables ---
$executables = @('heat-downloader.exe','heat-downloader-script.py')
$scriptFullPath = $null
foreach ($exe in $executables) {
$candidate = Join-Path $scriptsDir $exe
if (Test-Path $candidate) {
$scriptFullPath = $candidate
break
}
}
if (-not $scriptFullPath) {
Write-Err "No executable found in $scriptsDir."
exit 1
}

# --- 8) Test the installed script ---
try {
& $scriptFullPath '--help' | Out-Null
} catch {
Write-Err "Error running '$scriptFullPath'. Installation may be incorrect."
exit 1
}

# --- 9) Success message ---
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")
}
Loading
Loading