Skip to content

Commit

Permalink
Build executable with nuitka
Browse files Browse the repository at this point in the history
  • Loading branch information
laggykiller committed Oct 1, 2023
1 parent bc61fc6 commit ec0db48
Show file tree
Hide file tree
Showing 16 changed files with 217 additions and 233 deletions.
252 changes: 116 additions & 136 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Build

on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
# tags:
# - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

jobs:

Expand All @@ -20,21 +20,21 @@ jobs:
token: "${{ secrets.GITHUB_TOKEN }}"
name: Release ${{ github.ref_name }}

build-wheel:
name: Build wheel
needs: createrelease
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Build SDist and wheel
run: pipx run build

- uses: actions/upload-artifact@v3
with:
path: dist/*
# build-wheel:
# name: Build wheel
# needs: createrelease
# runs-on: ubuntu-20.04
# steps:
# - uses: actions/checkout@v3
# with:
# submodules: recursive

# - name: Build SDist and wheel
# run: pipx run build

# - uses: actions/upload-artifact@v3
# with:
# path: dist/*

build-binary:
name: Build packages
Expand All @@ -49,26 +49,25 @@ jobs:
python -m pip install --upgrade pip
pip install wheel
pip install -r requirements-build.txt
pyinstaller sticker_convert.spec
cd dist
python compile.py
move sticker-convert.dist sticker-convert
Compress-Archive -Path sticker-convert -DestinationPath sticker-convert-windows-x86_64.zip
cd ..
move dist\sticker-convert sticker-convert
dotnet tool install --global wix
wix extension add WixToolset.UI.wixext
python .\msicreator\createmsi.py msicreator.json
move *.msi dist\sticker-convert-windows-x86_64.msi
OUT_FILE_NAME: |
./dist/sticker-convert-windows-x86_64.zip
./dist/sticker-convert-windows-x86_64.msi
./sticker-convert-windows-x86_64.zip
./sticker-convert-windows-x86_64.msi
- os: macos-11
TARGET: macos
CMD_BUILD: |
python -m pip install --upgrade pip
python -m venv venv
source ./venv/bin/activate
pip install wheel delocate pyinstaller~=5.13.2
pip install wheel delocate nuitka
pip install -r requirements-src.txt
mkdir wheel_arm
mkdir wheel_x64
Expand All @@ -80,27 +79,10 @@ jobs:
mkdir dist
cp ./scripts/run_me_first.command ./dist
SC_TARGET_ARCH=x86_64 pyinstaller sticker_convert.spec
cd dist/
zip -r9 sticker-convert-macos-x86_64.zip sticker-convert.app run_me_first.command
rm -rf ./sticker-convert
rm -rf ./sticker-convert.app
cd ../
SC_TARGET_ARCH=arm64 pyinstaller sticker_convert.spec
cd dist/
zip -r9 sticker-convert-macos-arm64.zip sticker-convert.app run_me_first.command
rm -rf ./sticker-convert
rm -rf ./sticker-convert.app
cd ../
SC_TARGET_ARCH=universal2 pyinstaller sticker_convert.spec
cd dist/
python compile.py
mv ./sticker-convert.dist ./sticker-convert
zip -r9 sticker-convert-macos-universal2.zip sticker-convert.app run_me_first.command
OUT_FILE_NAME: |
./dist/sticker-convert-macos-x86_64.zip
./dist/sticker-convert-macos-arm64.zip
./dist/sticker-convert-macos-universal2.zip
OUT_FILE_NAME: ./sticker-convert-macos-universal2.zip
- os: ubuntu-20.04
TARGET: linux
CMD_BUILD: |
Expand All @@ -122,9 +104,7 @@ jobs:
# Bundling into appimage
ARCH=x86_64 ./appimagetool ./AppDir
chmod +x sticker-convert-x86_64.AppImage
mkdir dist
mv ./sticker-convert-x86_64.AppImage ./dist/sticker-convert-x86_64.AppImage
OUT_FILE_NAME: ./dist/sticker-convert-x86_64.AppImage
OUT_FILE_NAME: ./sticker-convert-x86_64.AppImage
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -148,99 +128,99 @@ jobs:
with:
files: ${{ matrix.OUT_FILE_NAME }}

build-docker:
name: Build Docker image and push
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# build-docker:
# name: Build Docker image and push
# runs-on: ubuntu-latest

# permissions:
# contents: read
# packages: write

# steps:
# - name: Checkout repository
# uses: actions/checkout@v3

# - name: Log in to Docker Hub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}

# - name: Login to GitHub Container Registry
# uses: docker/login-action@v2
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker (min-cli)
id: meta_min_cli
uses: docker/metadata-action@v4
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
flavor: |
suffix=-min-cli,onlatest=true
# - name: Extract metadata (tags, labels) for Docker (min-cli)
# id: meta_min_cli
# uses: docker/metadata-action@v4
# with:
# images: |
# ${{ github.repository }}
# ghcr.io/${{ github.repository }}
# flavor: |
# suffix=-min-cli,onlatest=true

- name: Extract metadata (tags, labels) for Docker (min-gui)
id: meta_min_gui
uses: docker/metadata-action@v4
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
flavor: |
suffix=-min-gui,onlatest=true
# - name: Extract metadata (tags, labels) for Docker (min-gui)
# id: meta_min_gui
# uses: docker/metadata-action@v4
# with:
# images: |
# ${{ github.repository }}
# ghcr.io/${{ github.repository }}
# flavor: |
# suffix=-min-gui,onlatest=true

- name: Extract metadata (tags, labels) for Docker (full)
id: meta_full
uses: docker/metadata-action@v4
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
# - name: Extract metadata (tags, labels) for Docker (full)
# id: meta_full
# uses: docker/metadata-action@v4
# with:
# images: |
# ${{ github.repository }}
# ghcr.io/${{ github.repository }}

- name: Build and push Docker image (min-cli)
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta_min_cli.outputs.tags }}
labels: ${{ steps.meta_min_cli.outputs.labels }}
target: min-cli
# - name: Build and push Docker image (min-cli)
# uses: docker/build-push-action@v4
# with:
# context: .
# push: true
# tags: ${{ steps.meta_min_cli.outputs.tags }}
# labels: ${{ steps.meta_min_cli.outputs.labels }}
# target: min-cli

- name: Build and push Docker image (min-gui)
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta_min_gui.outputs.tags }}
labels: ${{ steps.meta_min_gui.outputs.labels }}
target: min-gui

- name: Build and push Docker image (full)
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta_full.outputs.tags }}
labels: ${{ steps.meta_full.outputs.labels }}
target: full
# - name: Build and push Docker image (min-gui)
# uses: docker/build-push-action@v4
# with:
# context: .
# push: true
# tags: ${{ steps.meta_min_gui.outputs.tags }}
# labels: ${{ steps.meta_min_gui.outputs.labels }}
# target: min-gui

# - name: Build and push Docker image (full)
# uses: docker/build-push-action@v4
# with:
# context: .
# push: true
# tags: ${{ steps.meta_full.outputs.tags }}
# labels: ${{ steps.meta_full.outputs.labels }}
# target: full

upload-pypi:
name: Upload to pypi
needs: [build-wheel, build-binary]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: artifact
path: dist

- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
# upload-pypi:
# name: Upload to pypi
# needs: [build-wheel, build-binary]
# runs-on: ubuntu-latest
# steps:
# - uses: actions/download-artifact@v3
# with:
# # unpacks default artifact into dist/
# # if `name: artifact` is omitted, the action will create extra parent dir
# name: artifact
# path: dist

# - uses: pypa/[email protected]
# with:
# user: __token__
# password: ${{ secrets.PYPI_API_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ pyvenv.cfg
*.wixpdb
**/.wix

# Nuitka
**/*.build
**/*.dist

**/stickers_input
**/stickers_output
scripts/opt-comp-result
Expand Down
2 changes: 1 addition & 1 deletion AppImageBuilder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ AppDir:
icon: sticker-convert
version: latest
exec: usr/bin/python3.11
exec_args: "$APPDIR/usr/src/main.py $@"
exec_args: "$APPDIR/usr/src/sticker-convert.py $@"

apt:
arch: amd64
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ RUN apt purge -y python3-pip && \

VOLUME ["/app/stickers_input", "/app/stickers_output"]

ENTRYPOINT ["/app/main.py"]
ENTRYPOINT ["/app/sticker-convert.py"]

FROM jlesage/baseimage-gui:debian-11-v4 AS base-gui

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
- Upload: The program can create Xcode project for iMessage sticker pack, which could then be compiled and sideloaded using Xcode.

## How to use (GUI)
1. Run `sticker-convert.exe`, `sticker-convert.app` or `python3 src/main.py`
1. Run `sticker-convert.exe`, `sticker-convert.app` or `python3 src/sticker-convert.py`
2. Choose input source.
- If you are downloading, enter URL address if you want to download from (If applicable)
- If you are using local files, choose input directory. Defaults to a folder named 'stickers_input' in the same directory as the program. Put files you want to convert into that directory
Expand Down Expand Up @@ -230,7 +230,7 @@ Credentials options:
Save Signal and Telegram credentials.
```

If you are running python script directly, run with `src/main.py`
If you are running python script directly, run with `src/sticker-convert.py`

If you installed by pip, run with `sticker-convert` or `python -m sticker_convert`

Expand Down Expand Up @@ -307,7 +307,7 @@ docker run -d -it --name sticker-convert \
-v /path/to/your/stickers_input:/app/stickers_input \
-v /path/to/your/stickers_output:/app/stickers_output \
laggykiller/sticker-convert:latest \
python3 /app/main.py --help
python3 /app/sticker-convert.py --help
```

Alternative: Use docker-compose.yml
Expand Down
Loading

0 comments on commit ec0db48

Please sign in to comment.