Skip to content

Commit

Permalink
Merge pull request #65 from cassowaree/main
Browse files Browse the repository at this point in the history
Compile to direct executable on Windows x64, Ubuntu x64, and MacOS arm
  • Loading branch information
nythepegasus authored Aug 17, 2024
2 parents ecc2811 + 54b4871 commit 7afdc51
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@
**/values.dev.yaml
LICENSE
README.md

# nuitka
*.bin
*.exe
*.build
*.dist
*.onefile_dist
*compilation-report.xml
75 changes: 75 additions & 0 deletions .github/workflows/compile.yml
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
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,11 @@ cython_debug/

# macOS
.DS_Store

# nuitka
*.bin
*.exe
*.build
*.dist
*.onefile_dist
*compilation-report.xml
15 changes: 15 additions & 0 deletions COMPILE.md
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.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
This project allows you to start a server that wirelessly or via USB gives you JIT for iOS 17+ on Windows/macOS/Linux if you use the correct newer pymobiledevice3 version.

## How to get this running (Run with Administrator!)

### Option 1: Python install
```
python3 -m venv venv # Run inside SideJITStore directory!
Expand Down Expand Up @@ -35,9 +37,18 @@ python3 -m venv venv
pip3 install SideJITServer
SideJITServer --help
```

### Option 2: Direct download (if available)
Go to the latest [GitHub Release](https://github.com/nythepegasus/SideJITServer/releases/latest) and check if there are executable downloads, such as `SideJITServer-windows-x86_64.exe`, depending on your OS and your architecture.

Download the correct executable, and run it as Administrator from your terminal or Powershell following the directions below. If you are on Mac or Linux, you must first run `chmod +x ./(your downloaded .bin file)` before executing the file with sudo.

Python is not necessary for this approach.


# How to use SideJITServer?
- Make sure your device is connected!
- Make sure you're still inside the venv!
- Make sure you're still inside the venv, if applicable!
- Common Knowledge

Now run `SideJITServer --pair` and on your PC make sure you click on Trust this PC!
Expand Down
31 changes: 31 additions & 0 deletions SideJITServer/launch.py
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()
18 changes: 18 additions & 0 deletions sidejitserver-nuitka-package.config.yml
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'

0 comments on commit 7afdc51

Please sign in to comment.