Skip to content

Docs: How to compile to a standalone single file with Nuitka #133

Description

@laundmo

I have recently attempted, and after some effort managed, to compile a python ahk script to a standalone single file exe using nuitka.

Heres the process:

  • Install nuitka
  • Copy your AutoHotkey.exe into the same folder as your script
  • Use this code block to create your AHK instance, since when compiling to a single file with nuitka the path needs to be specified relative to __file__
    from ahk import AHK
    from pathlib import Path
    
    AHK_EXE = Path(__file__).parent / "AutoHotkey.exe"
    ahk = AHK(executable_path=str(AHK_EXE))
  • compile to a single file nuitka exe with the following command
    py -m nuitka --include-data-file=AutoHotkey.exe=./AutoHotkey.exe --include-package-data=ahk --onefile --standalone script.py
    --include-data-file will include the ahk exe in the single file app, and --include-package-data is required to include all the templates that this library uses.

I thought this might be interesting to document, since one of the best features of auto hotkey is IMO that it compiles to a standalone exe that i can share. I wasn't sure whether this is documentation that is wanted, or in what form/where, hence the issue and not a PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions