Build Python Executable #36
Workflow file for this run
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
| # This workflow builds a standalone Python executable for Windows using Nuitka | |
| # and attaches it to a new GitHub Release. | |
| name: Build Python Executable | |
| on: | |
| release: | |
| types: [created] # This workflow runs automatically whenever a new release is published. | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| permissions: | |
| contents: write # Required to write the release asset. | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.9' | |
| - name: Cache pip dependencies | |
| # This step caches installed packages to speed up subsequent runs. | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.pythonLocation }}\Lib\site-packages | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install Dependencies | |
| # A stable requirements file is the foundation of a reliable build. | |
| run: pip install -r requirements.txt | |
| - name: Cache Nuitka Compilation Results | |
| # This step significantly speeds up subsequent builds. | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| %APPDATA%\Nuitka\Nuitka\Cache\ | |
| ~\AppData\Local\Nuitka\Nuitka\Cache\ | |
| key: ${{ runner.os }}-nuitka-cache-${{ hashFiles('**/*.py', '**/requirements.txt') }} | |
| - name: Build with Nuitka | |
| # --- THE FINAL, POLISHED CONFIGURATION --- | |
| uses: Nuitka/Nuitka-Action@main | |
| with: | |
| nuitka-version: '2.6' | |
| msvc: 'latest' | |
| # --- PLUGIN CONFIGURATION --- | |
| # The tk-inter plugin is essential for GUI apps. Matplotlib is auto-detected. | |
| # Nuitka-Action auto-detects matplotlib, so we only need to specify tk-inter. | |
| enable-plugins: "tk-inter" | |
| script-name: PICA_Launcher_V5p1.py | |
| # The 'deployment' flag handles a one-file build. | |
| deployment: true | |
| # Use the modern option to disable the console. | |
| windows-console-mode: 'disable' | |
| # --- COMPILE SCRIPT DIRECTORIES AS PACKAGES --- | |
| # This is the correct way to include all .py files from your instrument modules. | |
| include-package: | | |
| Delta_mode_Keithley_6221_2182A | |
| Keithley_2400 | |
| Keithley_2400_Keithley_2182 | |
| Keithley_6517B | |
| LCR_Keysight_E4980A | |
| Lakeshore_350_340 | |
| Lock_in_amplifier | |
| Utilities | |
| windows-icon-from-ico: _assets/LOGO/UGC_DAE_CSR.ico | |
| # --- COPY NON-PYTHON ASSETS --- | |
| # These directories contain assets like images, manuals, etc. | |
| include-data-dir: | | |
| _assets=_assets | |
| include-data-files: | | |
| LICENSE=LICENSE | |
| README.md=README.md | |
| Updates.md=Updates.md | |
| # We explicitly tell Nuitka to put the output here. | |
| output-dir: build | |
| - name: Upload Executable to Release | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| # --- CORRECTED FILE PATH BELOW --- | |
| # The file is inside the 'build' directory we specified above. | |
| file: build/PICA_Launcher_V5p1.exe | |
| asset_name: PICA_Launcher-v${{ github.ref_name }}.exe | |
| tag: ${{ github.ref }} | |
| overwrite: true |