feat: install pip
This commit is contained in:
@@ -7,13 +7,13 @@ import { CustomNodesInstaller } from "./custom-nodes-downloader.js";
|
||||
import { AlternativesInstaller } from "./a1111-alter-downloader.js";
|
||||
import { SnapshotManager } from "./snapshot.js";
|
||||
import { ModelInstaller } from "./model-downloader.js";
|
||||
import { manager_instance, setManagerInstance, install_via_git_url, rebootAPI } from "./common.js";
|
||||
import { manager_instance, setManagerInstance, install_via_git_url, install_pip, rebootAPI } from "./common.js";
|
||||
|
||||
var docStyle = document.createElement('style');
|
||||
docStyle.innerHTML = `
|
||||
#cm-manager-dialog {
|
||||
width: 1000px;
|
||||
height: 420px;
|
||||
height: 450px;
|
||||
box-sizing: content-box;
|
||||
z-index: 10000;
|
||||
}
|
||||
@@ -782,6 +782,18 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
SnapshotManager.instance = new SnapshotManager(app, self);
|
||||
SnapshotManager.instance.show();
|
||||
}
|
||||
}),
|
||||
$el("button.cm-experimental-button", {
|
||||
type: "button",
|
||||
textContent: "Install PIP packages",
|
||||
onclick:
|
||||
() => {
|
||||
var url = prompt("Please enumerate the pip packages to be installed.\n\nExample: insightface opencv-python-headless>=4.1.1\n", "");
|
||||
|
||||
if (url !== null) {
|
||||
install_pip(url, self);
|
||||
}
|
||||
}
|
||||
})
|
||||
]),
|
||||
];
|
||||
|
||||
25
js/common.js
25
js/common.js
@@ -80,10 +80,35 @@ export function setManagerInstance(obj) {
|
||||
}
|
||||
|
||||
function isValidURL(url) {
|
||||
if(url.includes('&'))
|
||||
return false;
|
||||
|
||||
const pattern = /^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/;
|
||||
return pattern.test(url);
|
||||
}
|
||||
|
||||
export async function install_pip(packages) {
|
||||
if(packages.includes('&'))
|
||||
app.ui.dialog.show(`Invalid PIP package enumeration: '${packages}'`);
|
||||
|
||||
const res = await api.fetchApi(`/customnode/install/pip?packages=${packages}`);
|
||||
|
||||
if(res.status == 200) {
|
||||
app.ui.dialog.show(`PIP package installation is processed.<br>To apply the pip packages, please click the <button id='cm-reboot-button'><font size='3px'>RESTART</font></button> button in ComfyUI.`);
|
||||
|
||||
const rebootButton = document.getElementById('cm-reboot-button');
|
||||
const self = this;
|
||||
|
||||
rebootButton.addEventListener("click", rebootAPI);
|
||||
|
||||
app.ui.dialog.element.style.zIndex = 10010;
|
||||
}
|
||||
else {
|
||||
app.ui.dialog.show(`Failed to install '${packages}'<BR>See terminal log.`);
|
||||
app.ui.dialog.element.style.zIndex = 10010;
|
||||
}
|
||||
}
|
||||
|
||||
export async function install_via_git_url(url, manager_dialog) {
|
||||
if(!url) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user