Skip to content

feat: nicegui-app demo #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions .github/workflows/release-standalone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# See:
# - <https://github.com/tauri-apps/tauri-action>
# - <https://wsh032.github.io/pytauri/>

name: 'publish (standalone)'

on:
workflow_dispatch:
push:
branches:
- release

defaults:
run:
shell: bash

jobs:
publish-tauri:
permissions:
contents: write # required for creating github releases
strategy:
fail-fast: false
matrix:
include:
- platform: 'macos-latest' # for Arm based macs (M1 and above).
target: 'aarch64-apple-darwin'
- platform: 'macos-latest' # for Intel based macs.
target: 'x86_64-apple-darwin'
- platform: 'ubuntu-22.04'
target: 'x86_64-unknown-linux-gnu'
- platform: 'windows-latest'
target: 'x86_64-pc-windows-msvc'

runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4

- name: install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above.
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf

- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}

- name: Rust cache
uses: swatinem/rust-cache@v2

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

# see:
# - <https://github.com/astral-sh/python-build-standalone/releases>
# - <https://raw.githubusercontent.com/astral-sh/python-build-standalone/latest-release/latest-release.json>
# - <https://gregoryszorc.com/docs/python-build-standalone/main/running.html#obtaining-distributions>
- name: download python-build-standalone
env:
PYTHON_VERSION: '3.13.1' # update this by yourself
DATE: '20250115' # update this by yourself
TARGET: ${{ matrix.target }}
run: |
url="https://github.com/astral-sh/python-build-standalone/releases/download/${DATE}/cpython-${PYTHON_VERSION}+${DATE}-${TARGET}-install_only_stripped.tar.gz"
mkdir -p ./pyembed
curl -L $url | tar -xz -C ./pyembed

- name: install your project into the embedded python environment
env:
PYTAURI_STANDALONE: 1 # see your `setup.py`
PYTHON_PATH: ${{ matrix.platform == 'windows-latest' && './pyembed/python/python.exe' || './pyembed/python/bin/python3' }}
run: |
uv pip install \
--exact \
--python=${PYTHON_PATH} \
.

- name: set build environment variables (windows)
if: matrix.platform == 'windows-latest'
shell: powershell
run: |
$PYO3_PYTHON = (Resolve-Path -LiteralPath ".\pyembed\python\python.exe").Path
echo "PYO3_PYTHON=$PYO3_PYTHON" >> $env:GITHUB_ENV

- name: set build environment variables (linux)
if: matrix.platform == 'ubuntu-22.04'
shell: bash
# `nicegui-app` is your app `productName` in `tauri.conf.json`.
run: |
export PYO3_PYTHON=$(realpath ./pyembed/python/bin/python3)
export RUSTFLAGS=" \
-C link-arg=-Wl,-rpath,\$ORIGIN/../lib/nicegui-app/lib \
-L $(realpath ./pyembed/python/lib)"

echo "PYO3_PYTHON=$PYO3_PYTHON" >> $GITHUB_ENV
echo "RUSTFLAGS=$RUSTFLAGS" >> $GITHUB_ENV

- name: set build environment variables (macos)
if: matrix.platform == 'macos-latest'
shell: bash
run: |
export PYO3_PYTHON=$(realpath ./pyembed/python/bin/python3)
export RUSTFLAGS=" \
-C link-arg=-Wl,-rpath,@executable_path/../Resources/lib \
-L $(realpath ./pyembed/python/lib)"

echo "PYO3_PYTHON=$PYO3_PYTHON" >> $GITHUB_ENV
echo "RUSTFLAGS=$RUSTFLAGS" >> $GITHUB_ENV

- name: Build and bundle the app
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
releaseName: 'App v__VERSION__'
releaseBody: 'See the assets to download this version and install.'
releaseDraft: true
prerelease: false
args: '--target ${{ matrix.target }} --config tauri.bundle.json --verbose'
includeDebug: true
158 changes: 34 additions & 124 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,171 +1,81 @@
# Generated by Cargo
# will have compiled files and executables
/target/

# Generated by Tauri
# will have schema files for capabilities auto-completion
/gen/schemas

# Byte-compiled / optimized / DLL files
__pycache__/
.pytest_cache/
*.pdb
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
.venv/
env/
bin/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
include/
man/
venv/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt
pip-selfcheck.json

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# Rope
.ropeproject

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache
*.pot

# Scrapy stuff:
.scrapy
.DS_Store

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# UV
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
# PyCharm
.idea/

# pytype static type analyzer
.pytype/
# VSCode
.vscode/

# Cython debug symbols
cython_debug/
# Pyenv
.python-version

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# PyPI configuration file
.pypirc
/pyembed/
4 changes: 4 additions & 0 deletions .taurignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# See: <https://tauri.app/develop/#reacting-to-source-code-changes>

__pycache__
/pyembed/
Loading