Skip to content

Commit e5e299a

Browse files
committed
Initial commit
0 parents  commit e5e299a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1082
-0
lines changed

.github/workflows/publish.yaml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# See:
2+
# - <https://github.com/tauri-apps/tauri-action>
3+
# - <https://pytauri.github.io/pytauri/latest/usage/tutorial/build-standalone/>
4+
5+
name: "publish"
6+
7+
on:
8+
# Manual trigger
9+
workflow_dispatch:
10+
# On push to `release` branch
11+
push:
12+
branches:
13+
- release
14+
15+
defaults:
16+
run:
17+
shell: bash
18+
19+
jobs:
20+
publish-tauri:
21+
permissions:
22+
contents: write # required for creating github releases
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
include:
27+
- platform: "macos-14" # for Intel based macs.
28+
target: "x86_64-apple-darwin"
29+
- platform: "macos-14" # for Arm based macs (M1 and above).
30+
target: "aarch64-apple-darwin"
31+
- platform: "ubuntu-22.04"
32+
target: "x86_64-unknown-linux-gnu"
33+
- platform: "ubuntu-22.04-arm"
34+
target: "aarch64-unknown-linux-gnu"
35+
- platform: "windows-2022"
36+
target: "x86_64-pc-windows-msvc"
37+
- platform: "windows-11-arm"
38+
target: "aarch64-pc-windows-msvc"
39+
40+
runs-on: ${{ matrix.platform }}
41+
steps:
42+
- uses: actions/checkout@v4
43+
44+
- name: Install system dependencies (ubuntu only)
45+
if: runner.os == 'Linux'
46+
run: |
47+
sudo apt-get update
48+
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
49+
50+
- name: Install Rust stable
51+
uses: dtolnay/rust-toolchain@stable
52+
with:
53+
targets: ${{ matrix.target }}
54+
- name: Rust cache
55+
uses: swatinem/rust-cache@v2
56+
57+
- name: Install uv
58+
uses: astral-sh/setup-uv@v6
59+
with:
60+
enable-cache: true
61+
# version-file: "pyproject.toml"
62+
63+
- name: Install pnpm
64+
uses: pnpm/action-setup@v4
65+
with:
66+
# Optional: when there is a `packageManager` field in the `package.json`
67+
version: "latest"
68+
- name: Install Node.js
69+
uses: actions/setup-node@v4
70+
with:
71+
# Or: `node-version-file: package.json`
72+
node-version: lts/*
73+
cache: "pnpm"
74+
75+
- name: Install project dependencies
76+
run: |
77+
pnpm install
78+
79+
# See:
80+
# - <https://github.com/astral-sh/python-build-standalone/releases>
81+
# - <https://raw.githubusercontent.com/astral-sh/python-build-standalone/latest-release/latest-release.json>
82+
# - <https://gregoryszorc.com/docs/python-build-standalone/main/running.html#obtaining-distributions>
83+
- name: Download python-build-standalone
84+
env:
85+
PYTHON_VERSION: "3.13.7" # update this by yourself
86+
TAG: "20250828" # update this by yourself
87+
TARGET: ${{ matrix.target }}
88+
run: |
89+
url="https://github.com/astral-sh/python-build-standalone/releases/download/${TAG}/cpython-${PYTHON_VERSION}+${TAG}-${TARGET}-install_only_stripped.tar.gz"
90+
DEST_DIR="src-tauri/pyembed"
91+
92+
mkdir "$DEST_DIR"
93+
curl -L "$url" | tar -xz -C "$DEST_DIR"
94+
95+
# ref: <https://github.com/pytauri/pytauri/issues/99#issuecomment-2704556726>
96+
if [[ "${{ runner.os }}" == "macOS" ]]; then
97+
python_major_minor="${PYTHON_VERSION%.*}" # "3.13.7" -> "3.13"
98+
install_name_tool -id "@rpath/libpython${python_major_minor}.dylib" "$DEST_DIR/python/lib/libpython${python_major_minor}.dylib"
99+
fi
100+
101+
- name: Install the project into the embedded python environment
102+
env:
103+
PYTAURI_STANDALONE: 1 # see your `setup.py`
104+
PYTHON_PATH: ${{ runner.os == 'Windows' && './src-tauri/pyembed/python/python.exe' || './src-tauri/pyembed/python/bin/python3' }}
105+
run: |
106+
uv pip install \
107+
--exact \
108+
--compile-bytecode \
109+
--python=${{ env.PYTHON_PATH }} \
110+
./src-tauri
111+
112+
# Set build environment variables, see:
113+
# <https://pytauri.github.io/pytauri/latest/usage/tutorial/build-standalone/#build-and-bundle>
114+
115+
- name: Set build environment variables (windows)
116+
if: runner.os == 'Windows'
117+
shell: pwsh
118+
run: |
119+
$PYO3_PYTHON = (Resolve-Path -LiteralPath ".\src-tauri\pyembed\python\python.exe").Path
120+
echo "PYO3_PYTHON=$PYO3_PYTHON" >> $env:GITHUB_ENV
121+
122+
- name: Set build environment variables (linux)
123+
if: runner.os == 'Linux'
124+
shell: bash
125+
env:
126+
# `example-pytauri-app-react` is your app `productName` in `tauri.conf.json`
127+
PRODUCT_NAME: "example-pytauri-app-react"
128+
run: |
129+
PYO3_PYTHON=$(realpath ./src-tauri/pyembed/python/bin/python3)
130+
RUSTFLAGS=" \
131+
-C link-arg=-Wl,-rpath,\$ORIGIN/../lib/$PRODUCT_NAME/lib \
132+
-L $(realpath ./src-tauri/pyembed/python/lib)"
133+
134+
echo "PYO3_PYTHON=$PYO3_PYTHON" >> $GITHUB_ENV
135+
echo "RUSTFLAGS=$RUSTFLAGS" >> $GITHUB_ENV
136+
137+
- name: Set build environment variables (macos)
138+
if: runner.os == 'macOS'
139+
shell: bash
140+
run: |
141+
PYO3_PYTHON=$(realpath ./src-tauri/pyembed/python/bin/python3)
142+
RUSTFLAGS=" \
143+
-C link-arg=-Wl,-rpath,@executable_path/../Resources/lib \
144+
-L $(realpath ./src-tauri/pyembed/python/lib)"
145+
146+
echo "PYO3_PYTHON=$PYO3_PYTHON" >> $GITHUB_ENV
147+
echo "RUSTFLAGS=$RUSTFLAGS" >> $GITHUB_ENV
148+
149+
- name: Build and bundle the app
150+
uses: tauri-apps/tauri-action@v0
151+
env:
152+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
153+
with:
154+
tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
155+
releaseName: "App v__VERSION__"
156+
releaseBody: "See the assets to download this version and install."
157+
releaseDraft: true
158+
includeDebug: true # Optional, disable to speed up the build
159+
args: '--target=${{ matrix.target }} --config="src-tauri/tauri.bundle.json" --verbose'

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
25+
26+
/.venv/
27+
/target/

.vscode/extensions.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"recommendations": [
3+
"rust-lang.rust-analyzer",
4+
"vadimcn.vscode-lldb",
5+
"ms-python.python",
6+
"ms-python.vscode-pylance",
7+
"charliermarsh.ruff",
8+
"ms-python.debugpy",
9+
"tauri-apps.tauri-vscode",
10+
]
11+
}

Cargo.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[workspace]
2+
members = ["src-tauri"]
3+
resolver = "2"
4+
5+
[workspace.package]
6+
version = "0.1.0"
7+
edition = "2021"
8+
9+
10+
[profile.release]
11+
lto = "thin"
12+
13+
# See: <https://pytauri.github.io/pytauri/0.5/usage/tutorial/build-standalone/#configure-tauri-cli>
14+
[profile.bundle-dev]
15+
inherits = "dev"
16+
17+
[profile.bundle-release]
18+
inherits = "release"

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Tauri + React + Typescript
2+
3+
This template should help get you started developing with Tauri, React and Typescript in Vite.
4+
5+
## Recommended IDE Setup
6+
7+
- [VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer)

index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Tauri + React + Typescript</title>
8+
</head>
9+
10+
<body>
11+
<div id="root"></div>
12+
<script type="module" src="/src/main.tsx"></script>
13+
</body>
14+
</html>

package.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "example-pytauri-app-react",
3+
"private": true,
4+
"version": "0.1.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "tsc && vite build",
9+
"preview": "vite preview",
10+
"tauri": "tauri"
11+
},
12+
"dependencies": {
13+
"react": "^18.3.1",
14+
"react-dom": "^18.3.1",
15+
"@tauri-apps/api": "^2",
16+
"@tauri-apps/plugin-opener": "^2",
17+
"tauri-plugin-pytauri-api": "^0.8.0"
18+
},
19+
"devDependencies": {
20+
"@types/react": "^18.3.1",
21+
"@types/react-dom": "^18.3.1",
22+
"@vitejs/plugin-react": "^4.3.4",
23+
"typescript": "~5.6.2",
24+
"vite": "^6.3.6",
25+
"@tauri-apps/cli": "^2"
26+
}
27+
}

0 commit comments

Comments
 (0)