-
Notifications
You must be signed in to change notification settings - Fork 3
Run from source #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
LevFendi
wants to merge
11
commits into
main
Choose a base branch
from
run-from-source
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
01e2fc7
Add run.bat and point README to main mod install docs
LevFendi e440ed8
run.bat: add --force-embed flag to test embeddable Python path
LevFendi b8a4928
run.bat: simplify by using uv instead of manual Python/pip bootstrap
LevFendi ea173cb
run.bat: escape parens in echo inside if block
LevFendi e82ccac
Use build_main.py for venv setup to avoid duplicate management
LevFendi fd21f02
run.bat: escape parens in uv arch echo inside if block
LevFendi c926105
run.bat: verify playsound installed before marking setup complete
LevFendi 1d4da01
Avoid requiring MSVC to install fa_launcher_audio on Windows
LevFendi ef7d401
Rename run.bat to install-and-run.bat
LevFendi dfc187a
install-and-run.bat: remove MSVC from requirements comment
LevFendi 294020c
requirements.txt: use releases/latest/download URL for fa_launcher_audio
LevFendi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,180 @@ | ||
| @echo off | ||
| setlocal enabledelayedexpansion | ||
|
|
||
| :: ───────────────────────────────────────────────────────────────────────────── | ||
| :: Factorio Access Launcher - run without a compiled exe | ||
| :: | ||
| :: First run: downloads Python (if needed), sets up the environment via | ||
| :: build_main.py --setup-only, then starts the launcher. | ||
| :: Subsequent runs: skips setup and starts immediately. | ||
| :: | ||
| :: Requirements: | ||
| :: - Internet access (first run only) | ||
| :: - git (for the git+https://... playsound dependency and submodules) | ||
| :: ───────────────────────────────────────────────────────────────────────────── | ||
|
|
||
| set VENV_DIR=venv | ||
| set UV_DIR=.uv | ||
| set SETUP_MARKER=.setup_done | ||
|
|
||
| :: Run from the script's own directory so all relative paths are correct. | ||
| cd /d "%~dp0" | ||
|
|
||
| echo ============================================================ | ||
| echo Factorio Access Launcher | ||
| echo ============================================================ | ||
| echo. | ||
|
|
||
| :: ── Fast path: already set up ──────────────────────────────────────────────── | ||
|
|
||
| if exist "%VENV_DIR%\Scripts\python.exe" if exist "%SETUP_MARKER%" goto :run | ||
|
|
||
| echo First-time setup - this only runs once. | ||
| echo. | ||
|
|
||
| :: ── Step 1: Ensure git submodules are populated ─────────────────────────────── | ||
| :: ao2 and launcher-audio are submodules. If empty, pip install will fail. | ||
|
|
||
| git --version >nul 2>&1 | ||
| if !errorlevel! neq 0 ( | ||
| echo WARNING: git not found on PATH. | ||
| echo - Submodule packages ^(ao2, launcher-audio^) may already be present. | ||
| echo - The playsound dependency requires git to install from GitHub. | ||
| echo If setup fails, install git from https://git-scm.com and re-run. | ||
| echo. | ||
| ) else ( | ||
| if not exist "ao2\setup.py" if not exist "ao2\pyproject.toml" ( | ||
| echo Initialising git submodules... | ||
| git submodule update --init | ||
| if !errorlevel! neq 0 ( | ||
| echo ERROR: git submodule update failed. | ||
| pause | ||
| exit /b 1 | ||
| ) | ||
| ) | ||
| ) | ||
|
|
||
| :: ── Step 2: Find or download Python ────────────────────────────────────────── | ||
|
|
||
| set BASE_PYTHON= | ||
|
|
||
| :: Look for Python 3.11+ on PATH | ||
| for /f "tokens=2" %%v in ('python --version 2^>^&1') do set _SYS_VER=%%v | ||
| if defined _SYS_VER ( | ||
| for /f "tokens=1,2 delims=." %%a in ("!_SYS_VER!") do ( | ||
| if "%%a"=="3" if %%b GEQ 11 set BASE_PYTHON=python | ||
| ) | ||
| ) | ||
|
|
||
| if not defined BASE_PYTHON ( | ||
| echo Python 3.11+ not found on PATH. | ||
|
|
||
| if not exist "%UV_DIR%\uv.exe" ( | ||
| set ARCH=x86_64 | ||
| if "!PROCESSOR_ARCHITECTURE!"=="ARM64" set ARCH=aarch64 | ||
|
|
||
| echo Downloading uv ^(!ARCH!^)... | ||
| curl --fail --location --progress-bar ^ | ||
| -o uv.zip ^ | ||
| "https://github.com/astral-sh/uv/releases/latest/download/uv-!ARCH!-pc-windows-msvc.zip" | ||
| if !errorlevel! neq 0 ( | ||
| echo ERROR: Download failed. Check your internet connection. | ||
| if exist uv.zip del uv.zip | ||
| pause | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| powershell -NoProfile -Command ^ | ||
| "Expand-Archive -Path 'uv.zip' -DestinationPath '%UV_DIR%' -Force" | ||
| if !errorlevel! neq 0 ( | ||
| echo ERROR: Failed to extract uv.zip. | ||
| if exist uv.zip del uv.zip | ||
| pause | ||
| exit /b 1 | ||
| ) | ||
| del uv.zip | ||
| ) | ||
|
|
||
| echo Installing Python 3.11 via uv... | ||
| "%UV_DIR%\uv.exe" python install 3.11 | ||
| if !errorlevel! neq 0 ( | ||
| echo ERROR: Could not install Python 3.11. | ||
| pause | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| :: Get the path to the uv-managed Python executable | ||
| "%UV_DIR%\uv.exe" python find 3.11 > .python_path.tmp 2>&1 | ||
| set /p BASE_PYTHON=<.python_path.tmp | ||
| del .python_path.tmp | ||
| ) else ( | ||
| echo Found system Python !_SYS_VER! | ||
| ) | ||
|
|
||
| :: ── Step 3: Set up environment via build_main.py ───────────────────────────── | ||
| :: build_main.py --setup-only creates ./venv and installs dependencies, | ||
| :: then exits before running PyInstaller. | ||
|
|
||
| echo Setting up environment... | ||
| "%BASE_PYTHON%" build_main.py --setup-only | ||
|
|
||
| :: Verify the venv was actually created, since build_main.py doesn't | ||
| :: propagate pip errors as a non-zero exit code. | ||
| if not exist "%VENV_DIR%\Scripts\python.exe" ( | ||
| echo. | ||
| echo ERROR: Environment setup failed. Common causes: | ||
| echo - git not on PATH ^(needed for the playsound GitHub dependency^) | ||
| echo - git submodules empty ^(run: git submodule update --init^) | ||
| echo - no internet access | ||
| echo. | ||
| pause | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| :: Verify key packages installed correctly. | ||
| :: fa_launcher_audio requires Microsoft C++ Build Tools to compile its C extension. | ||
| :: playsound requires git to install from GitHub. | ||
| "%VENV_DIR%\Scripts\python.exe" -c "import fa_launcher_audio" >nul 2>&1 | ||
| if !errorlevel! neq 0 ( | ||
| echo. | ||
| echo ERROR: Dependencies did not install correctly ^(fa_launcher_audio is missing^). | ||
| echo This package requires Microsoft C++ Build Tools to compile. | ||
| echo. | ||
| echo Cleaning up so the next run retries setup... | ||
| rmdir /s /q "%VENV_DIR%" | ||
| echo. | ||
| echo Please install Microsoft C++ Build Tools, then run this script again. | ||
| echo Get them from: https://visualstudio.microsoft.com/visual-cpp-build-tools/ | ||
| echo ^(Install the "Desktop development with C++" workload^) | ||
| echo. | ||
| pause | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| "%VENV_DIR%\Scripts\python.exe" -c "import playsound" >nul 2>&1 | ||
| if !errorlevel! neq 0 ( | ||
| echo. | ||
| echo ERROR: Dependencies did not install correctly ^(playsound is missing^). | ||
| echo This usually means git was not on PATH during pip install. | ||
| echo. | ||
| echo Cleaning up so the next run retries setup... | ||
| rmdir /s /q "%VENV_DIR%" | ||
| echo. | ||
| echo Please ensure git is installed and on PATH, then run this script again. | ||
| echo Get git from https://git-scm.com | ||
| echo. | ||
| pause | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| :: Mark setup as complete so we skip all of this next time. | ||
| echo. > "%SETUP_MARKER%" | ||
|
|
||
| echo. | ||
| echo Setup complete. | ||
| echo. | ||
|
|
||
| :: ── Step 4: Run ─────────────────────────────────────────────────────────────── | ||
|
|
||
| :run | ||
| "%VENV_DIR%\Scripts\python.exe" main.py %* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bat script calls build_main.py to set up the environment but then using this added flag it exits early before attempting the python freeze.