Skip to content

Commit

Permalink
Migrate windows standalone to comfy-cli standalone build. (#7)
Browse files Browse the repository at this point in the history
* Windows build.

* Build windows.

* Add proc.

* Trigger build.

* Launch using python.exe

* Update for windows.

* Add logs.

* Add ls command.

* Go back a version.

* update [email protected]

* add `corepack enable` action before setting up node

* swtich to using the corepack feature branch of setup-node action

* fix contents of assets dir

---------

Co-authored-by: telamonian <[email protected]>
  • Loading branch information
robinjhuang and telamonian authored Aug 30, 2024
1 parent 0343541 commit bac144b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 20 deletions.
35 changes: 21 additions & 14 deletions .github/actions/build/windows/app/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ name: Windows Build App
description: Electron-Forge Build/Sign/publish
inputs:
DIGICERT_FINGERPRINT:
description: 'DigiCert SHA256 Fingerprint'
required: true
type: string
GITHUB_TOKEN:
description: 'GitHub Token'
required: true
type: string
sign-and-publish:
Expand All @@ -20,19 +22,24 @@ inputs:
runs:
using: composite
steps:
- name: Use Node.js
uses: actions/setup-node@v4
- name: Use Node.js 20.x
uses: JP250552/setup-node@feature/corepack
with:
node-version: 20
- run: yarn install
node-version: "20.x"
corepack: true
- run: yarn install --immutable
shell: cmd
- name: Download and prepare ComfyUI
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install ComfyUI and create standalone package
run: |
curl -L -o comfyui-win.7z https://github.com/Comfy-Org/python-dependencies/releases/download/embedded-windows-deps-cu11.8-py11.9-5/ComfyUI_windows_portable.7z
7z x comfyui-win.7z -odist/
move dist/ComfyUI_windows_portable/ComfyUI assets/UI/
move dist/ComfyUI_windows_portable/python_embedded assets/UI/
for /D /R %%i in (*pycache*) do rmdir /s /q "%%~i
pip install comfy-cli
cd assets
comfy --skip-prompt --workspace ./ComfyUI install --fast-deps --nvidia --cuda-version 12.1
comfy --workspace ./ComfyUI standalone --platform windows --proc x86_64
rm -rf python cpython*.tar.gz
shell: cmd
- name: Make app
shell: powershell
Expand All @@ -41,14 +48,14 @@ runs:
DEBUG: electron-forge:*
PUBLISH: ${{ inputs.sign-and-publish }}
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
run: npm run ${{inputs.sign-and-publish == true && 'publish' || 'make'}} -- ${{inputs.build-targets}}
run: yarn run ${{inputs.sign-and-publish == true && 'publish' || 'make'}} -- ${{inputs.build-targets}}
- name: Print SignLogs
if: ${{inputs.sign-and-publish == true && always()}}
continue-on-error: true
if: ${{inputs.sign-and-publish == true && always()}}
continue-on-error: true
shell: powershell
run: cd $HOME ; gc .signingmanager\logs\smksp.log
- name: verify signing
if: ${{inputs.sign-and-publish == true}}
run:
signtool verify /v /pa out/ComfyUI-win32-x64/ComfyUI.exe
shell: cmd
shell: cmd
5 changes: 4 additions & 1 deletion .github/workflows/debug_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Build App Windows Debug
on:
workflow_dispatch:
workflow_call:
push:
branches:
- rh-windows # just for testing

jobs:
build-windows-debug:
Expand All @@ -24,4 +27,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: comfyui-electron-win32-debug-build-${{env.sha_short}}
path: out/make/zip/win32/x64/*.zip
path: out/make/zip/win32/x64/*.zip
2 changes: 1 addition & 1 deletion forge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const config: ForgeConfig = {
return { entitlements: './assets/entitlements.mac.plist' };
},
},
extraResource: ['./assets/UI'],
extraResource: ['./assets/UI', './assets/ComfyUI', './assets/python.tgz'],
osxNotarize: {
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_PASSWORD,
Expand Down
21 changes: 17 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import('electron-squirrel-startup').then(ess => {
let pythonProcess: ChildProcess | null = null;
const host = '127.0.0.1'; // Replace with the desired IP address
const port = 8188; // Replace with the port number your server is running on

const scriptPath = 'assets/ComfyUI/main.py';
const packagedComfyUIExecutable = process.platform == 'win32' ? 'run_cpu.bat' : process.platform == 'darwin' ? 'ComfyUI' : 'ComfyUI';

const createWindow = () => {
Expand Down Expand Up @@ -75,8 +75,21 @@ const launchPythonServer = async () => {

if (app.isPackaged) {
//Production: use the bundled Python package
executablePath = path.join(process.resourcesPath, 'UI', packagedComfyUIExecutable);
pythonProcess = spawn(executablePath, { shell: true });
if (process.platform == 'win32') {
// On macOS, the Python executable is inside the app bundle
const pythonPath = path.join(process.resourcesPath, 'python', 'python.exe');
const scriptPath = path.join(process.resourcesPath, 'ComfyUI', 'main.py');

console.log('Python Path:', pythonPath);
console.log('Script Path:', scriptPath);

pythonProcess = spawn(pythonPath, [scriptPath], {
cwd: path.dirname(scriptPath)
});
} else {
executablePath = path.join(process.resourcesPath, 'UI', packagedComfyUIExecutable);
pythonProcess = spawn(executablePath, { shell: true });
}
} else {
// Development: use the fake Python server
executablePath = path.join(app.getAppPath(), 'ComfyUI', 'ComfyUI.sh');
Expand Down Expand Up @@ -146,4 +159,4 @@ app.on('activate', () => {
});

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.
// code. You can also put them in separate files and import them here.

0 comments on commit bac144b

Please sign in to comment.