Skip to content

Commit

Permalink
install windows python
Browse files Browse the repository at this point in the history
  • Loading branch information
KenCorma committed Oct 24, 2024
1 parent eb8e8c4 commit dbacc93
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 27 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"sign": "node debug/sign.js",
"start": "node ./scripts/launchdev.js",
"typescript": "yarn run tsc",
"postinstall": "node ./scripts/todesktop/beforeInstall.js",
"todesktop:beforeInstall": "./scripts/todesktop/beforeInstall.js",
"postinstall": "node ./scripts/todesktop/postInstall.js",
"todesktop:afterPack": "./scripts/todesktop/afterPack.js"
},
"devDependencies": {
Expand Down
34 changes: 8 additions & 26 deletions scripts/todesktop/beforeInstall.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
const { exec, execSync } = require("child_process");
const path = require("path");
const os = require('os');
const process = require("process");

async function postInstall() {
module.exports = async ({ pkgJsonPath, pkgJson, appDir, hookName }) => {
/**
* 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);
Expand All @@ -25,33 +18,22 @@ async function postInstall() {
}
};

const dirPath = process.cwd();
console.log(dirPath);
const dirPath = pkgJsonPath.replace("package.json", "");

console.log(os.platform());

if (os.platform() === "win32")
{
console.log("win ver");
const result1 = execSync(`python --version`,execOutput).toString();
const result1 = execSync('curl https://www.python.org/ftp/python/3.12.7/python-3.12.7-amd64.exe',execOutput).toString();
console.log(result1);
const result4 = execSync(`python -m pip install --upgrade pip`).toString();
console.log(result4);
const result2 = execSync(`python -m pip install comfy-cli`, execOutput).toString();
const result2 = execSync('./python-3.12.7-amd64.exe /quiet PrependPath=1 Include_test=0',execOutput).toString();
console.log(result2);
console.log("finish pip");
const result3 = execSync(`yarn run make:assets:nvidia`, execOutput).toString();
const result3 = execSync(`python --version`,execOutput).toString();
console.log(result3);
console.log("finish yarn run");

}

if (os.platform() === "darwin") {
console.log("mac ver");
const result1 = execSync(`ls`, execOutput).toString();
console.log(result1);
const result = execSync(`sh ${path.join(dirPath, 'scripts', 'signPython.sh')}`, execOutput).toString();
console.log("finish python");
}
};

postInstall();
}
};
57 changes: 57 additions & 0 deletions scripts/todesktop/postInstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const { exec, execSync } = require("child_process");
const path = require("path");
const os = require('os');
const process = require("process");

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());

if (os.platform() === "win32")
{
console.log("win ver");
const result1 = execSync(`python --version`,execOutput).toString();
console.log(result1);
const result4 = execSync(`python -3.12 -m pip install --upgrade pip`).toString();
console.log(result4);
const result2 = execSync(`python -3.12 -m pip install comfy-cli`, execOutput).toString();
console.log(result2);
console.log("finish pip");
const result3 = execSync(`yarn run make:assets:nvidia`, execOutput).toString();
console.log(result3);
console.log("finish yarn run");
}

if (os.platform() === "darwin") {
console.log("mac ver");
const result1 = execSync(`ls`, execOutput).toString();
console.log(result1);
const result = execSync(`export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin && sh ${path.join(dirPath, 'scripts', 'signPython.sh')}`, execOutput).toString();
console.log("finish python");
}
};

postInstall();

0 comments on commit dbacc93

Please sign in to comment.