-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from cassowaree/main
Compile to direct executable on Windows x64, Ubuntu x64, and MacOS arm
- Loading branch information
Showing
7 changed files
with
167 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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,75 @@ | ||
name: Compile Executables | ||
|
||
# Controls when the workflow will run | ||
on: | ||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
release: | ||
types: [ created ] | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
fail-fast: false # needed to keep running other os builds even if one fails | ||
|
||
matrix: | ||
os: | ||
- macos-latest | ||
- ubuntu-latest | ||
- windows-latest | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: # needed for tag info for nightly sdist builds | ||
fetch-depth: 0 | ||
fetch-tags: true | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' # nuitka 2.2 does not support 3.12 | ||
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified | ||
cache: 'pip' | ||
cache-dependency-path: | | ||
**/requirements*.txt | ||
# Install dependencies | ||
- name: Install Dependencies and Build sdist | ||
run: | | ||
pip install -r requirements.txt | ||
pip install -U build setuptools | ||
python -m build # create the sdist build to populate the __version__ var | ||
# Build python script into a standalone exe | ||
- name: Build Executable | ||
uses: Nuitka/Nuitka-Action@main | ||
with: | ||
nuitka-version: 2.2.3 # 2.3 does not work on mac for some reason | ||
script-name: SideJITServer/launch.py | ||
|
||
- name: Upload Compilation Report | ||
if: always() # run even if the compile failed | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ runner.os }} compilation report | ||
path: compilation-report.xml | ||
|
||
- name: Upload Executable | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ runner.os }} Build | ||
path: | | ||
build/*.exe | ||
build/*.bin | ||
build/*.app/**/* | ||
- name: Check if executable runs (.exe) | ||
if: ${{ runner.os == 'Windows' }} | ||
run: ./build/*.exe --version | ||
|
||
- name: Check if executable runs (.bin) | ||
if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }} | ||
run: ./build/*.bin --version |
This file contains 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 |
---|---|---|
|
@@ -162,3 +162,11 @@ cython_debug/ | |
|
||
# macOS | ||
.DS_Store | ||
|
||
# nuitka | ||
*.bin | ||
*.exe | ||
*.build | ||
*.dist | ||
*.onefile_dist | ||
*compilation-report.xml |
This file contains 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,15 @@ | ||
# Compilation notes for standalone no-python executable | ||
|
||
Compilation happens using a package called nuitka, which transpiles everything to C and then uses the appropriate C compiler to build an executable. It is handled in three files in this repo: | ||
|
||
1. `./sidejitserver-nuitka-package.config.yml` for platform-specific (Windows) dylib linking | ||
2. `./SideJITServer/launch.py` which is a duplicate of `main.py`, but using a package import and including necessary nuitka compilation flags including critical hidden imports | ||
3. `./.github/workflows/compile.yml` which lists compilation instructions on release or manual trigger. | ||
|
||
Compilation lasts between 25-50 minutes depending on platform from an empty cache, on the free tier GitHub Actions runners. Recompilation with an existing cache usually takes 7-15 minutes. | ||
|
||
When making a release, wait for the compilation to finish, and then download + attach the executables to the release after the jobs are finished. | ||
|
||
If you want to compile it yourself on your own machine, study the launch.py file and the github workflow to understand how to do it, and change any configs as necessary to fit your machine architecture. | ||
|
||
Note: currently pinned to python 3.11 and nuitka 2.2.3 since nuitka 2.3 does not work on Mac. |
This file contains 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 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,31 @@ | ||
# configuration and launch file for nuitka compilation | ||
|
||
# Make executable standalone | ||
# nuitka-project-if: {OS} in ("Windows", "Linux", "Darwin", "FreeBSD"): | ||
# nuitka-project: --onefile | ||
# nuitka-project: --onefile-tempdir-spec="{CACHE_DIR}/SideJITServer" | ||
# nuitka-project-else: | ||
# nuitka-project: --standalone | ||
|
||
# nuitka-project-if: {OS} == "Windows": | ||
# nuitka-project: --output-filename=SideJITServer-windows-x86_64.exe | ||
# nuitka-project: --include-module=jinxed.terminfo.vtwin10 | ||
# nuitka-project: --include-module=jinxed.terminfo.ansicon | ||
# nuitka-project: --include-module=jinxed.terminfo.xterm | ||
# nuitka-project: --include-module=jinxed.terminfo.xterm_256color | ||
# nuitka-project: --user-package-configuration-file=sidejitserver-nuitka-package.config.yml | ||
# nuitka-project-if: {OS} == "Linux": | ||
# nuitka-project: --output-filename=SideJITServer-linux-x86_64.bin | ||
# nuitka-project-if: {OS} == "Darwin": | ||
# nuitka-project: --output-filename=SideJITServer-mac-arm64.bin | ||
|
||
# nuitka-project: --include-module=zeroconf._utils.ipaddress | ||
# nuitka-project: --include-module=zeroconf._handlers.answers | ||
# nuitka-project: --include-module=pkg_resources.extern | ||
|
||
# nuitka-project: --report=compilation-report.xml | ||
|
||
from SideJITServer import start_server | ||
|
||
if __name__ == '__main__': | ||
start_server() |
This file contains 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,18 @@ | ||
# yamllint disable rule:line-length | ||
# yamllint disable rule:indentation | ||
# yamllint disable rule:comments-indentation | ||
# too many spelling things, spell-checker: disable | ||
--- | ||
|
||
- module-name: 'pytun_pmd3' | ||
dlls: | ||
- from_filenames: | ||
relative_path: 'wintun/bin/x86' | ||
prefixes: | ||
- 'wintun' | ||
when: 'win32 and arch_x86' | ||
- from_filenames: | ||
relative_path: 'wintun/bin/amd64' | ||
prefixes: | ||
- 'wintun' | ||
when: 'win32 and arch_amd64' |