Skip to content

Commit 975479f

Browse files
Merge branch 'main' into fix/markdown-linting
2 parents eca6db7 + f8ec976 commit 975479f

36 files changed

Lines changed: 1924 additions & 164 deletions

.github/workflows/build-and-release.yml

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,17 @@ jobs:
3232
- name: Build executable with PyInstaller
3333
run: |
3434
cd backend
35-
pyinstaller main.py --name PictoPy_Server --onedir --distpath dist
35+
pyinstaller PictoPy.spec
3636
37-
- name: Copy app folder
37+
- name: Verify no .onnx artifacts
38+
shell: pwsh
3839
run: |
39-
cd backend
40-
mkdir dist/PictoPy_Server/images
41-
robocopy app dist\PictoPy_Server\app /e
42-
if ($LASTEXITCODE -le 1) { exit 0 }
40+
$onnxFiles = Get-ChildItem -Path "backend/dist/PictoPy_Server" -Recurse -Filter "*.onnx" -File
41+
if ($onnxFiles) {
42+
Write-Error "Found bundled .onnx artifacts in backend/dist/PictoPy_Server:"
43+
$onnxFiles | ForEach-Object { Write-Error $_.FullName }
44+
exit 1
45+
}
4346
4447
- name: Create ZIP package
4548
run: |
@@ -74,14 +77,17 @@ jobs:
7477
- name: Build executable with PyInstaller
7578
run: |
7679
cd backend
77-
pyinstaller main.py --name PictoPy_Server --onedir --distpath dist
80+
pyinstaller PictoPy.spec
7881
79-
- name: Copy app folder
82+
- name: Verify no .onnx artifacts
83+
shell: bash
8084
run: |
81-
cd backend
82-
mkdir -p dist/PictoPy_Server/images
83-
mkdir -p dist/PictoPy_Server/app
84-
cp -r app/* dist/PictoPy_Server/app/
85+
onnx_files=$(find backend/dist/PictoPy_Server -type f -name "*.onnx")
86+
if [ -n "$onnx_files" ]; then
87+
echo "Found bundled .onnx artifacts in backend/dist/PictoPy_Server:"
88+
echo "$onnx_files"
89+
exit 1
90+
fi
8591
8692
- name: Create ZIP package
8793
run: |
@@ -114,14 +120,17 @@ jobs:
114120
- name: Build executable with PyInstaller
115121
run: |
116122
cd backend
117-
pyinstaller main.py --name PictoPy_Server --onedir --distpath dist
123+
pyinstaller PictoPy.spec
118124
119-
- name: Copy app folder
125+
- name: Verify no .onnx artifacts
126+
shell: bash
120127
run: |
121-
cd backend
122-
mkdir -p dist/PictoPy_Server/images
123-
mkdir -p dist/PictoPy_Server/app
124-
cp -r app/* dist/PictoPy_Server/app/
128+
onnx_files=$(find backend/dist/PictoPy_Server -type f -name "*.onnx")
129+
if [ -n "$onnx_files" ]; then
130+
echo "Found bundled .onnx artifacts in backend/dist/PictoPy_Server:"
131+
echo "$onnx_files"
132+
exit 1
133+
fi
125134
126135
- name: Create ZIP package
127136
run: |

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pnpm-debug.log*
99
lerna-debug.log*
1010

1111
backend/app/models/image-generation/*
12+
backend/app/models/ONNX_Exports/
1213

1314
node_modules
1415

backend/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ MANIFEST
3131
# before PyInstaller builds the exe, so as to inject date/other infos into it.
3232
*.manifest
3333
*.spec
34+
!PictoPy.spec
3435

3536
# Installer logs
3637
pip-log.txt

backend/PictoPy.spec

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# -*- mode: python ; coding: utf-8 -*-
2+
import os
3+
4+
a = Analysis(
5+
['main.py'],
6+
pathex=[],
7+
binaries=[],
8+
datas=[('app', 'app')],
9+
hiddenimports=['uvicorn.logging', 'uvicorn.loops', 'uvicorn.loops.auto', 'uvicorn.protocols', 'uvicorn.protocols.http', 'uvicorn.protocols.http.auto', 'uvicorn.protocols.websockets', 'uvicorn.protocols.websockets.auto', 'uvicorn.lifespan', 'uvicorn.lifespan.on', 'uvicorn.lifespan.off', 'psutil', 'platformdirs', 'httpx'],
10+
hookspath=[],
11+
hooksconfig={},
12+
runtime_hooks=[],
13+
excludes=[],
14+
win_no_prefer_redirects=False,
15+
win_private_assemblies=False,
16+
noarchive=False,
17+
)
18+
19+
def exclude_models(datas):
20+
filtered_datas = []
21+
for data in datas:
22+
# data is a tuple (dest, source, type)
23+
dest = data[0].replace(os.sep, '/')
24+
if 'app/models/' in dest and dest.endswith('.onnx'):
25+
continue
26+
filtered_datas.append(data)
27+
return filtered_datas
28+
29+
a.datas = exclude_models(a.datas)
30+
31+
pyz = PYZ(a.pure, a.zipped_data)
32+
33+
exe = EXE(
34+
pyz,
35+
a.scripts,
36+
[],
37+
exclude_binaries=True,
38+
name='PictoPy_Server',
39+
debug=False,
40+
bootloader_ignore_signals=False,
41+
strip=False,
42+
upx=False, # disabled until DLL compatibility is validated
43+
console=True,
44+
disable_windowed_traceback=False,
45+
argv_emulation=False,
46+
target_arch=None,
47+
codesign_identity=None,
48+
entitlements_file=None,
49+
)
50+
51+
coll = COLLECT(
52+
exe,
53+
a.binaries,
54+
a.zipfiles,
55+
a.datas,
56+
strip=False,
57+
upx=False, # disabled until DLL compatibility is validated
58+
upx_exclude=[],
59+
name='PictoPy_Server',
60+
)

backend/app/config/settings.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
from platformdirs import user_data_dir
21
import os
2+
import sys
3+
4+
from platformdirs import user_data_dir
35

4-
# Model Exports Path
5-
MODEL_EXPORTS_PATH = "app/models/ONNX_Exports"
6+
if getattr(sys, "frozen", False):
7+
MODEL_EXPORTS_PATH = os.path.join(user_data_dir("PictoPy"), "models")
8+
else:
9+
MODEL_EXPORTS_PATH = os.path.normpath(
10+
os.path.join(os.path.dirname(__file__), "..", "models", "ONNX_Exports")
11+
)
612

713
# Microservice URLs
814
SYNC_MICROSERVICE_URL = "http://localhost:52124"

0 commit comments

Comments
 (0)