Skip to content

Commit

Permalink
Cleaned up and added Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
KenCorma committed Oct 29, 2024
1 parent 29b0e04 commit b877505
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 246 deletions.
4 changes: 2 additions & 2 deletions .github/actions/build/windows/todesktop/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Windows Build App
description: Electron-Forge Build/Sign/publish
name: Windows Build to ToDesktop
description: Will build the project then send the project files to ToDesktop to be compiled into installers.
inputs:
GITHUB_TOKEN:
description: 'GitHub Token'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish_linux.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# .github/workflows/publish_linux.yml
# 2024.10.28 : Might not be used anymore as ToDesktop Handles all publishing
name: Release Linux app

on:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish_macos.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# .github/workflows/publish_macos.yml
# 2024.10.28 : Might not be used anymore as ToDesktop Handles all publishing
name: Release MacOS app

on:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish_windows.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# .github/workflows/publish_windows.yml
# 2024.10.28 : Might not be used anymore as ToDesktop Handles all publishing
name: Release Windows app

on:
Expand Down
168 changes: 0 additions & 168 deletions forge.config.ts

This file was deleted.

7 changes: 0 additions & 7 deletions scripts/signPython.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ python -m pip install --upgrade pip >/dev/null
wait
pip install comfy-cli >/dev/null
wait
ls
cd assets
comfy --skip-prompt --here install --fast-deps --m-series --manager-url https://github.com/Comfy-Org/manager-core >/dev/null
wait
cd ComfyUI
cd ..
comfy --here standalone --platform macos
wait
Expand All @@ -16,12 +14,8 @@ rm -rf ComfyUI/custom_nodes/ComfyUI-Manager/.git
mkdir python2/
tar -xzf python.tgz -C python2/
rm python.tgz
find . -type l ! -exec test -e {} \; -delete
wait
find . -name '*.tar.gz' -delete
wait
ls
echo Sign Libs and Bins
mv python python3
mv python2/python python
mkdir output2
Expand All @@ -31,6 +25,5 @@ cd python
filelist=("lib/libpython3.12.dylib" "lib/python3.12/lib-dynload/_crypt.cpython-312-darwin.so" "bin/uv" "bin/uvx" "bin/python3.12")
for file in ${filelist[@]}; do mkdir -p `dirname ../output2/$file` && mv "$file" ../output2/"$file"; done
cd ..
echo Rezip
tar -czf python.tgz python/
rm -rf python
4 changes: 3 additions & 1 deletion scripts/todesktop/afterPack.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const os = require('os');
const fs = require('fs/promises');
const path = require('path');
const { exec } = require('child_process');

module.exports = async ({ appOutDir, packager, outDir }) => {
/**
Expand All @@ -14,6 +13,9 @@ module.exports = async ({ appOutDir, packager, outDir }) => {
* arch - number - the architecture of the app. ia32 = 0, x64 = 1, armv7l = 2, arm64 = 3, universal = 4.
*/

// The purpose of this script is to move the built python and comfy files from assets to the resource folder of the app
// We can not add them to extraFiles as that is done prior to building, where we need to move them AFTER

if (os.platform() === "darwin") {
const appName = packager.appInfo.productFilename;
const appPath = path.join(`${appOutDir}`, `${appName}.app`);
Expand Down
28 changes: 7 additions & 21 deletions scripts/todesktop/beforeInstall.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { exec, execSync, spawnSync } = require("child_process");
const { spawnSync } = require("child_process");
const path = require("path");
const os = require('os');

Expand All @@ -10,28 +10,14 @@ module.exports = async ({ pkgJsonPath, pkgJson, appDir, hookName }) => {
* hookName - string - the name of the hook ("todesktop:beforeInstall" or "todesktop:afterPack")
*/

const execOutput = (error,stdout,stderr) => {
console.log("exec out: " , stdout);
console.log("exec stderr: " ,stderr);
if (error !== null) {
console.log(`exec error: ${error}`);
}
};

const dirPath = pkgJsonPath.replace("package.json", "");

console.log(os.platform());
console.log('Before Yarn Install' , os.platform());

if (os.platform() === "win32")
{
const result1 = spawnSync('curl' ,['-s', 'https://www.python.org/ftp/python/3.12.7/python-3.12.7-amd64.exe'],{shell:true,stdio: 'ignore'},execOutput).toString();
console.log(result1);
const result2 = spawnSync('python-3.12.7-amd64.exe', ['/quiet', 'InstallAllUsers=1','PrependPath=1', 'Include_test=0'],{shell:true,stdio: 'ignore'},execOutput).toString();
console.log(result2);

}

if (os.platform() === "darwin") {

// ToDesktop currently does not have the min 3.12 python installed.
// Download the installer then install it
// Change stdio to get back the logs if there are issues.
const result1 = spawnSync('curl' ,['-s', 'https://www.python.org/ftp/python/3.12.7/python-3.12.7-amd64.exe'],{shell:true,stdio: 'ignore'}).toString();
const result2 = spawnSync('python-3.12.7-amd64.exe', ['/quiet', 'InstallAllUsers=1','PrependPath=1', 'Include_test=0'],{shell:true,stdio: 'ignore'}).toString();
}
};
63 changes: 18 additions & 45 deletions scripts/todesktop/postInstall.js
Original file line number Diff line number Diff line change
@@ -1,70 +1,43 @@
const { exec, execSync, spawnSync, spawn } = require("child_process");
const { spawnSync } = require("child_process");
const path = require("path");
const os = require('os');
const process = require("process");
const fs = require('fs-extra');
//const fs = require('fs-extra');

async function postInstall() {
/**
* pkgJsonPath - string - path to the package.json file
* pkgJson - object - the parsed package.json file
* appDir - string - the path to the app directory
* hookName - string - the name of the hook ("todesktop:beforeInstall" or "todesktop:afterPack")
*/


const firstInstallOnToDesktopServers =
process.env.TODESKTOP_CI && process.env.TODESKTOP_INITIAL_INSTALL_PHASE;

if (!firstInstallOnToDesktopServers) return;


const execOutput = (error,stdout,stderr) => {
console.log("exec out: " , stdout);
console.log("exec stderr: " ,stderr);
if (error !== null) {
console.log(`exec error: ${error}`);
}
};

const dirPath = process.cwd();
console.log(dirPath);

console.log(os.platform());
console.log('After Yarn Install' , os.platform());

if (os.platform() === "win32")
{
console.log("win ver");
const result1 = execSync(`py -0`,execOutput).toString();
console.log(result1);
const result4 = spawnSync(`py`, ['-3.12', '-m', 'pip' ,'install' ,'--upgrade pip'],{shell:true,stdio: 'ignore'}).toString();
console.log(result4);
const result2 = spawnSync(`py`, ['-3.12 ','-m' ,'pip' ,'install comfy-cli'], {shell:true,stdio: 'ignore'}).toString();
console.log(result2);
console.log("finish pip");
const result3 = 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();
console.log(result3);
const result5 = spawnSync('set PATH=C:\\hostedtoolcache\\windows\\Python\\3.12.7\\x64\\Scripts;%PATH% && cd assets && comfy-cli --here standalone' ,[''],{shell:true,stdio: 'inherit'}).toString();
console.log(result5);
const result = spawnSync('mkdir -p assets\\ComfyUI\\user\\default' ,[''],{shell:true,stdio: 'inherit'}).toString();
console.log("finish yarn run");
spawnSync('cd assets && dir' ,[''],{shell:true,stdio: 'inherit'}).toString();
// Change stdio to get back the logs if there are issues.
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();
console.log("Finish Comfy Manager Install and Rehydration");
}

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

// 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
/*
fs.createFileSync('./src/macpip.txt');
fs.writeFileSync('./src/macpip.txt',JSON.stringify({
log: result.stdout.toString(),
err:result.stderr.toString()
}));
console.log("finish python");
*/
console.log("Finish Python & Comfy Install for Mac");
}
};

Expand Down
Loading

0 comments on commit b877505

Please sign in to comment.