Skip to content

Commit 6d8de3e

Browse files
committed
Merge branch 'main' into dev
2 parents 3290fae + 69cb102 commit 6d8de3e

File tree

5 files changed

+75
-147
lines changed

5 files changed

+75
-147
lines changed

.github/workflows/pyinstaller-build.yml renamed to .github/workflows/flet-pack.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ jobs:
1414
os: ["macos-latest", "windows-latest"]
1515

1616
steps:
17-
- uses: actions/checkout@v2
18-
- uses: actions/setup-python@v2
17+
- uses: actions/checkout@main
18+
- uses: actions/setup-python@main
1919
with:
2020
python-version: 3.10.7
2121
- run: pip install -r requirements.txt
2222
- run: pip install -r requirements_build.txt
2323
- run: pip install --no-dependencies -e .
24-
- run: python scripts/build_app.py --one-file
24+
- run: python scripts/pack_app.py
2525
# Optionally verify that it works (provided that it does not need user interaction)
2626
#- run: ./dist/your-code/your-code
27-
- uses: actions/upload-artifact@v3
27+
- uses: actions/upload-artifact@main
2828
with:
2929
name: Tuttle-${{ github.sha }}-${{ matrix.os }}
3030
path: dist/

.github/workflows/python-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ jobs:
1919
python-version: ["3.8", "3.9", "3.10", "3.11"]
2020

2121
steps:
22-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@main
2323
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v2
24+
uses: actions/setup-python@main
2525
with:
2626
python-version: ${{ matrix.python-version }}
2727
- name: Install dependencies

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ $ python app/app.py
123123
1. Requires [GTK](https://www.gtk.org).
124124

125125

126+
## Build
127+
128+
To build an app bundle, run
129+
130+
```shell
131+
python scripts/pack_app.py
132+
```
126133

127134

128135
## Contributing

scripts/build_app.py

Lines changed: 0 additions & 141 deletions
This file was deleted.

scripts/pack_app.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
from typing import Optional
2+
3+
import sys
4+
from pathlib import Path
5+
import typer
6+
from loguru import logger
7+
import subprocess
8+
9+
import tuttle
10+
11+
app_path = "app/app.py"
12+
app_name = "Tuttle"
13+
icon_path = "app/assets/icon/macos/AppIcon.icns"
14+
15+
# files to be added to the app bundle
16+
added_files = [
17+
("templates", "./templates"),
18+
("tuttle_tests/data", "./tuttle_tests/data"),
19+
]
20+
21+
# options to be passed to flet pack
22+
pack_options = [
23+
("--name", app_name),
24+
("--icon", icon_path),
25+
("--product-name", app_name),
26+
("--product-version", tuttle.__version__),
27+
]
28+
29+
if sys.platform.startswith("win"):
30+
delimiter = ";"
31+
else:
32+
delimiter = ":"
33+
34+
added_data_options = []
35+
for src, dst in added_files:
36+
added_data_options += ["--add-data", f"{src}{delimiter}{dst}"]
37+
pack_options_unpacked = [item for pair in pack_options for item in pair]
38+
39+
40+
def main(
41+
install_dir: Optional[Path] = typer.Option(
42+
None, "--install-dir", "-i", help="Where to install the app"
43+
),
44+
):
45+
if install_dir:
46+
logger.info(f"removing app from {install_dir}")
47+
subprocess.call(["rm", "-rf", f"{install_dir}/Tuttle.app"], shell=False)
48+
49+
logger.info("building app")
50+
pack_command = (
51+
["flet", "pack", app_path] + added_data_options + pack_options_unpacked
52+
)
53+
logger.info(f"calling flet with command: {' '.join(pack_command)}")
54+
print(pack_command)
55+
subprocess.call(
56+
pack_command,
57+
shell=False,
58+
)
59+
60+
61+
if __name__ == "__main__":
62+
typer.run(main)

0 commit comments

Comments
 (0)