Skip to content

Commit a58c099

Browse files
committed
try nuitka
1 parent 66b1922 commit a58c099

6 files changed

Lines changed: 71 additions & 6 deletions

File tree

.github/workflows/build.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,39 @@ jobs:
5252
cache: "pip"
5353
cache-dependency-path: "requirements/requirements*.txt"
5454
- name: Install dependencies
55-
# install only the really required modules before the pyinstaller build
55+
# install only the really required modules before the nuitka build
5656
run: |
5757
pip install -r requirements/requirements-build.txt
5858
python download_binaries.py
59-
- name: Build executables with pyinstaller
59+
- name: Build executables with nuitka
60+
shell: bash
6061
run: |
61-
python -m PyInstaller jimmy.spec
62+
python -m nuitka --version
63+
# --onefile-no-compression to avoid "ValueError: compression parameter 'nb_workers' received an illegal value 4; the valid range is [0, 0]"
64+
python -m nuitka \
65+
--assume-yes-for-downloads \
66+
--standalone --onefile \
67+
--follow-imports \
68+
--follow-import-to=jimmy \
69+
$(python generate_nuitka_config.py) \
70+
--user-package-configuration-file=nuitka-anyblock_exporter.config.yml \
71+
--include-data-dir=./bin=bin \
72+
--output-filename="$(python obtain_executable_name.py)" \
73+
--output-dir=dist \
74+
jimmy/jimmy_cli.py
75+
#- name: Build Executable
76+
# uses: Nuitka/Nuitka-Action@main
77+
# with:
78+
# nuitka-version: main
79+
# script-name: jimmy/jimmy_cli.py
80+
# mode: app
6281
- name: Release
6382
uses: softprops/action-gh-release@v3
6483
# release only if there is a release tag
6584
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
6685
with:
6786
files: |
68-
./dist/jimmy*
87+
./dist/jimmy-*
6988
./bin/copyright.pandoc
7089
- name: Check executable size
7190
shell: bash

generate_nuitka_config.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env python3
2+
"""Generate Nuitka include modules list from jimmy/formats directory."""
3+
4+
from pathlib import Path
5+
import sys
6+
7+
formats_dir = Path("jimmy/formats")
8+
format_modules = []
9+
10+
for file in sorted(formats_dir.glob("*.py")):
11+
if file.name != "__init__.py":
12+
module_name = f"jimmy.formats.{file.stem}"
13+
format_modules.append(module_name)
14+
15+
# Generate command-line arguments
16+
args = ["--include-module=" + module for module in format_modules]
17+
print(" ".join(args))
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- module-name: "anyblock_exporter"
2+
data-files:
3+
- patterns:
4+
- "config.yaml"

obtain_executable_name.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import os
2+
import platform
3+
4+
5+
# Generate the executable name based on OS.
6+
system = platform.system().lower()
7+
# print("libc:", platform.libc_ver())
8+
9+
# need to correspond to ".github/workflows/build.yml"
10+
match os.getenv("RUNNER_MACHINE"):
11+
case "windows-latest" | "ubuntu-22.04":
12+
pass # default - nothing to do
13+
case "ubuntu-latest":
14+
# Differentiate between old glibc (above, for maximum compatibility)
15+
# and newer glibc (here, just for testing).
16+
system += "-new-glibc"
17+
case "ubuntu-22.04-arm":
18+
system += "-" + platform.machine().lower()
19+
case "macos-latest" | "macos-15-intel":
20+
# Differentiate between ARM and Intel based Macs.
21+
system += "-" + platform.machine().lower()
22+
executable_name = f"jimmy-{system}"
23+
print(executable_name)
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
-r requirements.txt
2-
pyinstaller==6.21.0
2+
Nuitka[app] @ git+https://github.com/Nuitka/Nuitka.git@develop
3+
ordered-set # Speeds up compilation significantly
4+
zstandard # Reduces final EXE size by 30-50%
35
hatch==1.17.0
46
twine==6.2.0

test/smoke-test.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ bats_require_minimum_version 1.5.0
44

55
# environment variables
66

7-
JIMMY_EXE="../dist/jimmy*"
7+
JIMMY_EXE="../dist/jimmy-*"
88
DEFAULT_OUTPUT_FOLDER="$(mktemp -d)/smoke_test_bats_tmp"
99
TEST_DATA_DIR=./data/test_data
1010
REFERENCE_DATA_DIR=./data/reference_data

0 commit comments

Comments
 (0)