Try Nuitka instead of PyInstaller for creating the executable #678
This file contains hidden or 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
| name: build | |
| on: | |
| push: | |
| branches: | |
| - master | |
| tags: | |
| - "**" | |
| paths-ignore: | |
| - "**.md" | |
| pull_request: | |
| paths-ignore: | |
| - "**.md" | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: build | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| contents: write | |
| env: | |
| RUNNER_MACHINE: ${{ matrix.os }} # TODO: Is there a built-in env variable? | |
| PYTHONPATH: jimmy | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # available images: https://github.com/actions/runner-images?tab=readme-ov-file#available-images | |
| # "macos-latest" to support ARM based MACs | |
| # "macos-15-intel" to support Intel based MACs | |
| # "ubuntu-22.04" to get the lowest possible glibc version for compatibility | |
| os: ["windows-latest", "ubuntu-22.04", "ubuntu-22.04-arm", "macos-latest", "macos-15-intel"] | |
| # build "macos-15-intel" executable only at release | |
| # https://github.com/orgs/community/discussions/26253?sort=top#discussioncomment-3250989 | |
| is_release: | |
| - ${{ startsWith(github.ref, 'refs/tags/v') }} | |
| exclude: | |
| - is_release: false | |
| os: "macos-15-intel" | |
| - is_release: false | |
| os: "ubuntu-latest" | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| # fetch all tags for the "git describe" later | |
| fetch-depth: 0 | |
| submodules: true | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14.0" | |
| cache: "pip" | |
| cache-dependency-path: "requirements/requirements*.txt" | |
| - name: Install dependencies | |
| # install only the really required modules before the nuitka build | |
| run: | | |
| pip install -r requirements/requirements-build.txt | |
| python download_binaries.py | |
| - name: Build executables with nuitka | |
| shell: bash | |
| run: | | |
| # --jobs=1 to avoid "ValueError: compression parameter 'nb_workers' received an illegal value 4; the valid range is [0, 0]" | |
| python -m nuitka \ | |
| --assume-yes-for-downloads \ | |
| --standalone --onefile \ | |
| --follow-imports \ | |
| --follow-import-to=jimmy \ | |
| $(python generate_nuitka_config.py) \ | |
| --include-data-dir=./bin=bin \ | |
| --output-filename="$(python obtain_executable_name.py)" \ | |
| --output-dir=dist \ | |
| jimmy/jimmy_cli.py | |
| #- name: Build Executable | |
| # uses: Nuitka/Nuitka-Action@main | |
| # with: | |
| # nuitka-version: main | |
| # script-name: jimmy/jimmy_cli.py | |
| # mode: app | |
| - name: Release | |
| uses: softprops/action-gh-release@v3 | |
| # release only if there is a release tag | |
| if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
| with: | |
| files: | | |
| ./dist/jimmy* | |
| ./bin/copyright.pandoc | |
| - name: Check executable size | |
| shell: bash | |
| run: ls -lh ./dist | |
| - name: Setup bats and bats libs | |
| uses: bats-core/bats-action@4.0.0 | |
| with: | |
| # workaround for macos, see https://github.com/bats-core/bats-action/issues/57#issuecomment-4004063838 | |
| support-path: "${{ github.workspace }}/tests/bats-support" | |
| assert-path: "${{ github.workspace }}/tests/bats-assert" | |
| detik-path: "${{ github.workspace }}/tests/bats-detik" | |
| file-path: "${{ github.workspace }}/tests/bats-file" | |
| - name: Smoke test | |
| shell: bash | |
| working-directory: ./test # run in a different directory to make sure that the paths are working | |
| run: bats smoke-test.bats --timing | |
| # - name: Scan for viruses (just for information) | |
| # if: runner.os == 'Linux' | |
| # run: | | |
| # sudo apt install -y clamav | |
| # clamscan ./dist/jimmy* |