Skip to content

Commit

Permalink
Yarn Dev/Make Fixes, Local ComfyCLI Fix (#139)
Browse files Browse the repository at this point in the history
* Fixes #124

* Fixes #129
  • Loading branch information
KenCorma authored Oct 31, 2024
1 parent 6836432 commit 821f894
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 43 deletions.
1 change: 0 additions & 1 deletion .github/workflows/publish_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
- name: Build
uses: ./.github/actions/build/windows/todesktop
with:
sign-and-publish: true
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
TODESKTOP_ACCESS_TOKEN: ${{secrets.TODESKTOP_ACCESS_TOKEN}}
TODESKTOP_EMAIL: ${{secrets.TODESKTOP_EMAIL}}
Binary file removed assets/output/bin/python3.12
Binary file not shown.
Binary file removed assets/output/bin/uv
Binary file not shown.
Binary file removed assets/output/bin/uvx
Binary file not shown.
Binary file removed assets/output/lib/libpython3.12.dylib
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions builder-debug.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import { Configuration } from 'electron-builder';

const debugConfig: Configuration = {
files: ['package.json', 'README.md', 'src/**', '.vite/**'],
extraResources: ['./assets/ComfyUI', './assets/python.tgz', './assets/UI'],
extraFiles: [{ from: './assets', to: process.platform === 'darwin' ? './Resources' : './resources' }],
beforeBuild: './scripts/preMake.js',
win: {
asar: false,
icon: './assets/UI/Comfy_Logo.ico',
target: 'zip',
signtoolOptions: null,
},
mac: {
icon: './assets/UI/Comfy_Logo.icns',
target: 'zip',
sign: null,
identity: null,
},
linux: {
icon: './assets/UI/Comfy_Logo_x256.png',
Expand Down
2 changes: 1 addition & 1 deletion forge.env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ declare global {
viteDevServers: Record<string, import('vite').ViteDevServer>;
}
interface ProcessEnv {
PUBLISH?: string | boolean;
PUBLISH: boolean;
APPLE_ID: string;
APPLE_PASSWORD: string;
APPLE_TEAM_ID: string;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"format:fix": "prettier --write .",
"prepare": "husky",
"make": "yarn run vite:compile && electron-builder build --config=builder-debug.config.ts",
"make:nvidia": "yarn run make -- --nvidia",
"make:assets:amd": "cd assets && comfy-cli --skip-prompt --here install --fast-deps --amd --manager-url https://github.com/Comfy-Org/manager-core && comfy-cli --here standalone && yarn run clone-settings-extension && yarn run clean:git",
"make:assets:cpu": "cd assets && comfy-cli --skip-prompt --here install --fast-deps --cpu --manager-url https://github.com/Comfy-Org/manager-core && comfy-cli --here standalone && node ../scripts/env.mjs && yarn run clone-settings-extension && yarn run clean:git",
"make:assets:nvidia": "cd assets && comfy-cli --skip-prompt --here install --fast-deps --nvidia --manager-url https://github.com/Comfy-Org/manager-core && comfy-cli --here standalone && yarn run clone-settings-extension && yarn run clean:git",
Expand Down
2 changes: 0 additions & 2 deletions scripts/launchdev.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env node

const {build, createServer} = require('vite');
const electronPath = require('electron');
const {spawn} = require('child_process');
Expand Down
39 changes: 39 additions & 0 deletions scripts/preMake.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const { exec, execSync, spawnSync, spawn } = require("child_process");
const path = require("path");
const os = require('os');
const process = require("process");
const fs = require('fs-extra');

module.exports = async ({ appOutDir, packager, outDir }) => {

const firstInstallOnToDesktopServers =
process.env.TODESKTOP_CI && process.env.TODESKTOP_INITIAL_INSTALL_PHASE;
// Do NOT run on CI
if (process.env.CI || firstInstallOnToDesktopServers) return;

const isNvidia = process.argv[process.argv.length-1] === '--nvidia';

console.log(`<BUILDING COMFYCLI ON ${os.platform()} ${isNvidia && "Nvidia Ver"}>`)

// If this folder is here assume comfy has already been installed
if (fs.existsSync('./assets/ComfyUI'))
{
console.log(">COMFYUI ALREADY BUILT<");
return
}

if (os.platform() === 'darwin') {
spawnSync('py -m pip install comfy-cli', [''], { shell: true, stdio:['ignore','ignore','inherit'] });
spawnSync('yarn run make:assets:macos', [''], { shell: true, stdio: "inherit" });
}

if (os.platform() === 'win32')
{
spawnSync('py -m pip install comfy-cli', [''], { shell: true, stdio:['ignore','ignore','inherit'] });
const result = spawnSync(`python -c "import os,sysconfig;print(sysconfig.get_path(""scripts"",f""{os.name}_user""))"`, [''], { shell: true, stdio: "pipe" }).stdout.toString();
const localPythonModulePath = `PATH=${result.replaceAll('\\','\\\\').trim()};%PATH%`;
spawnSync(`set ${localPythonModulePath} && yarn run make:assets:${isNvidia ? 'nvidia' : 'cpu'}`, [''], { shell: true, stdio: "inherit" });

}
console.log(">PREMAKE FINISH<");
}
29 changes: 0 additions & 29 deletions scripts/signPython.sh

This file was deleted.

10 changes: 5 additions & 5 deletions scripts/todesktop/postInstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ async function postInstall() {
const resultUpgradePip = spawnSync(`py`, ['-3.12', '-m', 'pip' ,'install' ,'--upgrade pip'],{shell:true,stdio: 'ignore'}).toString();
const resultInstallComfyCLI = spawnSync(`py`, ['-3.12 ','-m' ,'pip' ,'install comfy-cli'], {shell:true,stdio: 'ignore'}).toString();
console.log("Finish PIP & ComfyCLI Install");
const resultComfyManagerInstall = spawnSync('set PATH=C:\\hostedtoolcache\\windows\\Python\\3.12.7\\x64\\Scripts;%PATH% && cd assets && comfy-cli --skip-prompt --here install --fast-deps --nvidia --manager-url https://github.com/Comfy-Org/manager-core && comfy-cli --here standalone && mkdir -p ComfyUI\\user\\default' ,[''],{shell:true,stdio: 'inherit'}).toString();
const resultComfyManagerInstall = spawnSync('set PATH=C:\\hostedtoolcache\\windows\\Python\\3.12.7\\x64\\Scripts;%PATH% && yarn run make:assets:nvidia' ,[''],{shell:true,stdio: 'inherit'}).toString();
console.log("Finish Comfy Manager Install and Rehydration");
}

if (os.platform() === "darwin") {
const dirPath = process.cwd();
const shPath = path.join(dirPath, 'scripts', 'signPython.sh');
const resultUnixifySH = spawnSync('sed', [`-i ''` , `'s/\\r//g'` , shPath],{shell:true,stdio:'inherit'});
const resultPythonInstall = spawnSync('sh', [shPath],{shell:true,stdio: 'pipe'});

const resultUpgradePip = spawnSync(`py`, ['-3.12', '-m', 'pip' ,'install' ,'--upgrade pip'],{shell:true,stdio: 'ignore'}).toString();
const resultInstallComfyCLI = spawnSync(`py`, ['-3.12 ','-m' ,'pip' ,'install comfy-cli'], {shell:true,stdio: 'ignore'}).toString();
const resultComfyManagerInstall = spawnSync('yarn run make:assets:macos' ,[''],{shell:true,stdio: 'inherit'}).toString();

// Do not delete, useful if there are build issues with mac
// TODO: Consider making a global build log as ToDesktop logs can be hit or miss
Expand Down
5 changes: 3 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,10 @@ async function loadRendererIntoMainWindow(): Promise<void> {
log.error('Trying to load renderer into main window but it is not ready yet.');
return;
}
if (typeof MAIN_WINDOW_VITE_DEV_SERVER_URL !== 'undefined') {

if (process.env.VITE_DEV_SERVER_URL) {
log.info('Loading Vite Dev Server');
await mainWindow.loadURL(MAIN_WINDOW_VITE_DEV_SERVER_URL);
await mainWindow.loadURL(process.env.VITE_DEV_SERVER_URL);
log.info('Opened Vite Dev Server');
mainWindow.webContents.openDevTools();
} else {
Expand Down
1 change: 1 addition & 0 deletions vite.main.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default defineConfig((env) => {
define: {
VITE_NAME: JSON.stringify('COMFY'),
'process.env.COMFYUI_CPU_ONLY': `"${process.env.COMFYUI_CPU_ONLY}"`,
'process.env.PUBLISH': `"${process.env.PUBLISH}"`,
...(env.command !== 'build' && {
VITE_DEV_SERVER_URL: JSON.stringify('http://localhost:5173/'),
MAIN_WINDOW_VITE_DEV_SERVER_URL: JSON.stringify('http://localhost:5173/'),
Expand Down

0 comments on commit 821f894

Please sign in to comment.