Skip to content
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
45 changes: 27 additions & 18 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@ jobs:
- name: Build executable with PyInstaller
run: |
cd backend
pyinstaller main.py --name PictoPy_Server --onedir --distpath dist
pyinstaller PictoPy.spec
Comment thread
coderabbitai[bot] marked this conversation as resolved.

- name: Copy app folder
- name: Verify no .onnx artifacts
shell: pwsh
run: |
cd backend
mkdir dist/PictoPy_Server/images
robocopy app dist\PictoPy_Server\app /e
if ($LASTEXITCODE -le 1) { exit 0 }
$onnxFiles = Get-ChildItem -Path "backend/dist/PictoPy_Server" -Recurse -Filter "*.onnx" -File
if ($onnxFiles) {
Write-Error "Found bundled .onnx artifacts in backend/dist/PictoPy_Server:"
$onnxFiles | ForEach-Object { Write-Error $_.FullName }
exit 1
}

- name: Create ZIP package
run: |
Expand Down Expand Up @@ -74,14 +77,17 @@ jobs:
- name: Build executable with PyInstaller
run: |
cd backend
pyinstaller main.py --name PictoPy_Server --onedir --distpath dist
pyinstaller PictoPy.spec

- name: Copy app folder
- name: Verify no .onnx artifacts
shell: bash
run: |
cd backend
mkdir -p dist/PictoPy_Server/images
mkdir -p dist/PictoPy_Server/app
cp -r app/* dist/PictoPy_Server/app/
onnx_files=$(find backend/dist/PictoPy_Server -type f -name "*.onnx")
if [ -n "$onnx_files" ]; then
echo "Found bundled .onnx artifacts in backend/dist/PictoPy_Server:"
echo "$onnx_files"
exit 1
fi

- name: Create ZIP package
run: |
Expand Down Expand Up @@ -114,14 +120,17 @@ jobs:
- name: Build executable with PyInstaller
run: |
cd backend
pyinstaller main.py --name PictoPy_Server --onedir --distpath dist
pyinstaller PictoPy.spec

- name: Copy app folder
- name: Verify no .onnx artifacts
shell: bash
run: |
cd backend
mkdir -p dist/PictoPy_Server/images
mkdir -p dist/PictoPy_Server/app
cp -r app/* dist/PictoPy_Server/app/
onnx_files=$(find backend/dist/PictoPy_Server -type f -name "*.onnx")
if [ -n "$onnx_files" ]; then
echo "Found bundled .onnx artifacts in backend/dist/PictoPy_Server:"
echo "$onnx_files"
exit 1
fi

- name: Create ZIP package
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pnpm-debug.log*
lerna-debug.log*

backend/app/models/image-generation/*
backend/app/models/ONNX_Exports/

node_modules

Expand Down
1 change: 1 addition & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ MANIFEST
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
!PictoPy.spec

# Installer logs
pip-log.txt
Expand Down
60 changes: 60 additions & 0 deletions backend/PictoPy.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# -*- mode: python ; coding: utf-8 -*-
import os

a = Analysis(
['main.py'],
pathex=[],
binaries=[],
datas=[('app', 'app')],
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'],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
noarchive=False,
)

def exclude_models(datas):
filtered_datas = []
for data in datas:
# data is a tuple (dest, source, type)
dest = data[0].replace(os.sep, '/')
if 'app/models/' in dest and dest.endswith('.onnx'):
continue
filtered_datas.append(data)
return filtered_datas

a.datas = exclude_models(a.datas)
Comment thread
rahulharpal1603 marked this conversation as resolved.

pyz = PYZ(a.pure, a.zipped_data)

exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='PictoPy_Server',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False, # disabled until DLL compatibility is validated
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)

coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=False, # disabled until DLL compatibility is validated
upx_exclude=[],
name='PictoPy_Server',
)
12 changes: 9 additions & 3 deletions backend/app/config/settings.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
from platformdirs import user_data_dir
import os
import sys

from platformdirs import user_data_dir

# Model Exports Path
MODEL_EXPORTS_PATH = "app/models/ONNX_Exports"
if getattr(sys, "frozen", False):
MODEL_EXPORTS_PATH = os.path.join(user_data_dir("PictoPy"), "models")
else:
MODEL_EXPORTS_PATH = os.path.normpath(
os.path.join(os.path.dirname(__file__), "..", "models", "ONNX_Exports")
)

# Microservice URLs
SYNC_MICROSERVICE_URL = "http://localhost:52124"
Expand Down
Loading
Loading