Skip to content

Run from source#8

Draft
LevFendi wants to merge 11 commits intomainfrom
run-from-source
Draft

Run from source#8
LevFendi wants to merge 11 commits intomainfrom
run-from-source

Conversation

@LevFendi
Copy link
Copy Markdown
Member

@LevFendi LevFendi commented Mar 7, 2026

The overall aim of this group of PRs is to add the option for Windows users to run from source with relatively low hassle. This is meant as a decisive workaround to launcher exe files being flagged by antivirus software.

Changes

  • ADD install-and-run.bat as a one-click script to handle most of install and run work. It does the following:
    • Install Py 3.11 standalone using uv
    • Create the venv using build_main.py
    • Use git to setup ao2 and playsound (unless they are already present)
    • Download the prebuilt version of launcher-audio (explained below)
    • Use pip to setup other packages
    • Install everything
    • Run the the launcher
  • ADD a CI workflow to the launcher audio repo to publish pre-built Windows wheels so that build from source can download the pre-built wheel from the repo instead of having to install MSVC to compile it.
  • ADD Build from source instructions to the main repo readme: Users need to install git and clone the launcher repo to the correct place. Then they run the bat script.
  • WIP: Remove git dependency by switching to publishing zip releases of the launcher repo that include ao2 and playsound vendored as part of the download. This way, the entire user setup will be Download, Unzip, Run.

Related PRs

Testing history

Windows 11, no MSVC installed, fresh copy of repo (not a git clone)

requirements.txt was temporarily modified to point fa_launcher_audio at the v0.1.0-rc1 pre-release wheel URL
directly (since releases/latest/download does not resolve to pre-releases). The final PR uses
releases/latest/download which will resolve once the launcher-audio PR is merged and a release is tagged.

install-and-run.bat was run from a copy of the repo placed inside a Factorio zip install directory. The script
downloaded Python 3.11 via uv, installed all dependencies including fa_launcher_audio from the pre-built GitHub
Release wheel (no C compiler required), and launched the launcher successfully to the main menu, which then successfully runs the game.

LevFendi and others added 2 commits March 7, 2026 16:24
- run.bat: sets up Python (downloads embeddable if needed), installs
  dependencies into a venv or embedded Python, and runs main.py.
  Subsequent runs skip setup and start immediately.
  Fixes vs initial version:
    - Fast path now requires setup marker for both venv and embed paths,
      so a failed mid-setup run doesn't skip to launch with missing deps
    - Check errorlevel after get-pip.py execution
    - Quote BASE_PYTHON and VENV_DIR in venv creation command
    - Detect ARM64 vs amd64 for correct embeddable download URL
    - Quote SETUP_MARKER in echo redirect
- README: replace duplicated install instructions with a link to the
  main FactorioAccess repo README as the single source of truth.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@LevFendi LevFendi self-assigned this Mar 7, 2026
@LevFendi LevFendi added documentation Improvements or additions to documentation enhancement New feature or request labels Mar 7, 2026
LevFendi and others added 7 commits March 8, 2026 19:52
uv manages Python version installation and venv creation itself,
replacing the embeddable Python download, .pth editing, and get-pip
bootstrap with a single binary. ARM64 detection is still needed for
the uv binary itself.

Removes --force-embed flag (no longer applicable with uv).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Unescaped ) was closing the if block prematurely, causing
'may was unexpected at this time' error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- build_main.py: add --setup-only flag that exits after venv creation
  and dep install, before re-invoking itself to run PyInstaller
- run.bat: drop independent venv/pip logic; call build_main.py
  --setup-only instead. uv is retained as a fallback to download
  Python 3.11 if not found on PATH, with the executable path then
  passed to build_main.py. Venv dir aligned to ./venv to match
  build_main.py. Verify venv exists after setup since build_main.py
  does not propagate pip errors as a non-zero exit code.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
build_main.py uses os.system() without checking pip's return code, so
a failed playsound install (git dep) went undetected. Now we import
playsound to verify, and if missing we wipe the venv so the next run
retries setup rather than hitting the fast path with missing deps.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- requirements.txt: install pre-built wheel from GitHub Releases on
  Windows (stable URL, no C compiler needed); keep source build for
  Linux/macOS
- run.bat: check fa_launcher_audio imports (not just playsound) and
  give a clear error pointing to MSVC Build Tools if it's missing;
  document the MSVC requirement in the header comment

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The script does more than just run - on first launch it downloads Python,
sets up a venv, and installs all dependencies. The new name sets clearer
expectations for users.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread build_main.py
Copy link
Copy Markdown
Member Author

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.

Pre-built wheels mean Windows users no longer need C++ Build Tools.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@LevFendi
Copy link
Copy Markdown
Member Author

Tested bat script on Windows 11, no MSVC installed, fresh copy of launcher repo (not a git clone). Output summary:

  ============================================================
   Factorio Access Launcher
  ============================================================

  First-time setup - this only runs once.

  Python 3.11+ not found on PATH.
  Installing Python 3.11 via uv...
  Python 3.11 is already installed
  Setting up environment...

  [...dependency collection and install...]

  Downloading fa_launcher_audio-0.1.0-cp311-cp311-win_amd64.whl (1.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 2.9 MB/s

  Successfully installed [...] fa_launcher_audio-0.1.0 [...]

  Setup complete.

  Updating FactorioAccess to v0.16.57
  Main menu
  1: Launch last played
  2: Single player
  ...




Switches from the rc1 test URL to the stable latest-release URL now that
testing is complete.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant