GithubHelp home page GithubHelp logo

sayyid5416 / pyinstaller Goto Github PK

View Code? Open in Web Editor NEW
22.0 2.0 14.0 57 KB

Customisable GitHub Action to package python scripts into executables for different OS's

License: MIT License

Python 100.00%
github-actions pyinstaller linux mac windows python

pyinstaller's Introduction

Check all available usable tags here
You can also use any major tags like @v1 for any @v1.*.*


๐Ÿ”ฐ PyInstaller

  • This action packages the python source code into executables using pyinstaller.
  • Use this action in your workflow to create & upload executables to GitHub (as artifacts).
  • Use inputs to configure this action.
  • Use outputs to get information from this action.



๐Ÿ”ฐ Features

๐Ÿ’  Multi-OS support

  • Create executable for different kinds of os like linux, windows, mac etc.
  • Specify OS in jobs.<job-id>.runs-on=<your-os-name> in your workflow file.
  • see examples for more info.

๐Ÿ’  .py and .spec support

  • You can use either .py or .spec file to create the executable.
  • Specify it in inputs.spec: <file.py/file.spec>.
  • When .py file is used, generated .spec file will also be uploaded as artifact.
  • Modify your .spec file according to your needs.

๐Ÿ’  Third party modules

  • Write your third party modules in a file (Ex: requirements.txt) , and
  • Use inputs.requirements: <path-to-your-requirement-file>.

๐Ÿ’  Pyinstaller options

  • Specify pyinstaller options in inputs.options: <comma-seperated-options-here>.
  • .py and .spec both supports different kind of options.
  • Check list of all supported options here.

๐Ÿ’  Python and Pyinstaller versions

  • You can specify any python version for the executable.
  • Specify specific python-version in inputs.python_ver: <python-version-here>.
  • Specify specific pyinstaller-version in inputs.pyinstaller_ver: <pyinstaller-version-here-with-proper-signs, like '==5.13.2'>.

๐Ÿ’  Executable uploads

  • You can control if generated executable needs to be uploaded as artifact.
  • You can choose a name of your liking.
  • You can also customise the level of compression for the archive.
  • Specify the artifact name in inputs.upload_exe_with_name: <name-here>.



๐Ÿ”ฐ Inputs & Outputs

  • Some inputs are required, while rest are optional.
  • Check detailed info about these inputs & outputs here.

๐Ÿ’  Available Inputs

Input Default
(- = empty string)
Description
spec (required) - Path of your .py or .spec file
requirements - Path of your requirements.txt file
options - Options to set for pyinstaller command
python_ver 3.10 Specific python version you want to use
python_arch x64 Specific python architecture you want to use
pyinstaller_ver - Specific pyinstaller version you want to use
(with proper signs, like ==5.13.2)
exe_path ./dist Path on runner-os, where executable will be stored
upload_exe_with_name - Upload exe_ artifact with this name. Else, it won't upload
clean_checkout true If true, perform a clean checkout; if false, skip cleaning. Cleaning will remove all existing local files not in the repository during checkout. If you use utilities like pyinstaller-versionfile, set this to false.
compression_level 6 Level of compression for archive.
Range: 0 and 9.
(0 = No compression, 9 = Max compression).

๐Ÿ’  Available Outputs

Output Description
executable_path Path on runner-os, where executable will be stored
is_uploaded true, if packaged executable has been uploaded as artifact

๐Ÿ’  Supported Pyinstaller options

For .py For .py For .spec
--uac-admin --name <NAME>, -n <NAME> --ascii, -a
--uac-uiaccess --icon <FILEICON>, -i <FILEICON> --upx-dir <UPX_DIR>
--noupx --key <KEY>
--onedir, -D --upx-dir <UPX_DIR>
--onefile, -F --upx-exclude <FILE>
--ascii, -a --add-data <SRC;DEST or SRC:DEST>
--console, --nowindowed, -c --add-binary <SRC;DEST or SRC:DEST>
--windowed, --noconsole, -w --collect-data <MODULENAME>
--collect-all <MODULENAME>



๐Ÿ”ฐ Examples

jobs:
  pyinstaller-build:
    runs-on: <windows-latest / ubuntu-latest / ..... etc>
    steps:
      - name: Create Executable
        uses: sayyid5416/pyinstaller@v1
        with:
          python_ver: '3.6'
          pyinstaller_ver: '==5.13.2'
          spec: 'src/build.spec'
          requirements: 'src/requirements.txt'
          upload_exe_with_name: 'My executable'
          options: --onefile, --name "My App", --windowed, 



๐Ÿ”ฐ Main Repository : sayyid5416/pyinstaller

pyinstaller's People

Contributors

aliencaocao avatar nackophilz avatar sayyid5416 avatar young-lord avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pyinstaller's Issues

Incompatible Python versions causing TypeError: 'type' object is not subscriptable

The readme example is Python 3.6:
https://github.com/sayyid5416/pyinstaller/blame/454cc5f88cbfd6a1f7f5e6b9b96a0216be7f1720/README.md#L111

The code uses features introduced in Python 3.9:
https://github.com/sayyid5416/pyinstaller/blame/454cc5f88cbfd6a1f7f5e6b9b96a0216be7f1720/src/mods.py#L60

The discrepancy causes the following error:
"TypeError: 'type' object is not subscriptable"

The easy fix for the discrepancy would be to use Python >=3.9 in the example, or you may want to consider using different import options to make the code compatible.

weird version.txt not found

Pls see aliencaocao/netease_cloudmusic_discord_rpc#4

TLDR: i specified to use version.txt in the same dir as the source file for the exe version info but pyinstaller complains it is not found, even though ls shows the file is there. I cannot reproduce this locally so I'm guess it has something to do with how this action works.

[ENHANCEMENT] Add --collect*

Hi there!

I wanted to know, would it be possible, or is it planned to add the option included in py installer namely the "--collect-all"?

It's very useful, especially for the pyGithub and plexAPI module for one of my projects, and when I add it it doesn't recognize it :)

Node.js 16 actions are deprecated for some dependency actions

Hi,

I am seeing this warning in my actions builds:

Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: actions/setup-python@v4, actions/checkout@v3, actions/upload-artifact@v3. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.

Are you planning to use latest versions of these dependencies in future versions?

Also, action/upload-artifact@v4 cannot be used for any artifact uploaded with actions/upload-artifact@v3, it is in the breaking changes.

Thanks!

macos Unsupported spec Error

Great work! I have this action that runs perfectly on windows-latest and ubuntu-latest, but fails to run on macos-latest with:
Run sayyid5416/pyinstaller@v1
with:
python_ver: 3.10
spec: ui.py
requirements: requirements.txt
upload_exe_with_name: s3backup
options: --onefile, --name "s3backup", --windowed
exe_path: ./dist
Run python "/Users/runner/work/_actions/sayyid5416/pyinstaller/v1/src/checks.py"
python "/Users/runner/work/_actions/sayyid5416/pyinstaller/v1/src/checks.py"
shell: /bin/bash --noprofile --norc -e -o pipefail {0}
env:
spec: ui.py
upload_exe_with_name: s3backup
File "/Users/runner/work/_actions/sayyid5416/pyinstaller/v1/src/checks.py", line 25
f"Unsupported input 'spec = {spec}' was provided. Supported types: {', '.join(supported_spec)}",
^
SyntaxError: invalid syntax

My action:
jobs:
pyinstaller-build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Create Executable
uses: sayyid5416/pyinstaller@v1
with:
python_ver: '3.10'
spec: 'ui.py'
requirements: 'requirements.txt'
upload_exe_with_name: 's3backup'
options: --onefile, --name "s3backup", --windowed

Missing version.rc file for pyinstaller when using pyinstaller-versionfile

Hi

I'm using pyinstaller-versionfile in a prior to pyinstaller to generate the version.rc file. When the github action runs, the version.rc file is not present for pyinstaller.

What am I doing wrong?

Here is an example of my actions.yml file

name: CI

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  pyinstaller_build:
    runs-on: windows-latest
    outputs:
      version: ${{ steps.set_version.outputs.version }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      
      # Install dependencies
      - name: Setup Python
        uses: actions/setup-python@v2
        with:
          python-version: '3.11.7'
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install pyinstaller-versionfile

      # Add step to create version file before PyInstaller build
      - name: Create Version File
        run: create-version-file version_metadata.yml --outfile version.rc

      - name: LS version.rc (before pyinstaller)
        run: |
          ls ./
          mkdir test

      - name: Create Executable
        uses: sayyid5416/pyinstaller@v1
        with:
          python_ver: '3.11.7'
          pyinstaller_ver: '==6.3.0'
          spec: 'presenterfocus.py'
          requirements: 'requirements.txt'
          upload_exe_with_name: 'PresenterFocus'
          options: --onefile --windowed --icon "icon.png" --name "PresenterFocus"

      - name: LS version.rc (after pyinstaller)
        run: |
          ls ./
          # the version.rc and test dir are not present here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.