Skip to content

Commit

Permalink
Use user chosen path for Python installation. (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
robinjhuang authored Oct 15, 2024
1 parent a7dfeaf commit 2faf6eb
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ if (!gotTheLock) {
});
});
await handleFirstTimeSetup();
const { userResourcesPath, appResourcesPath, pythonInstallPath, modelConfigPath, basePath } =
await determineResourcesPaths();
const { appResourcesPath, pythonInstallPath, modelConfigPath, basePath } = await determineResourcesPaths();
SetupTray(mainWindow, basePath);
port = await findAvailablePort(8000, 9999).catch((err) => {
log.error(`ERROR: Failed to find available port: ${err}`);
Expand Down Expand Up @@ -760,7 +759,7 @@ function createDirIfNotExists(dirPath: string): void {
}
}

async function createComfyConfigFile(userSettingsPath: string): Promise<void> {
function createComfyConfigFile(userSettingsPath: string): void {
const configContent: any = {
'Comfy.ColorPalette': 'dark',
'Comfy.NodeLibrary.Bookmarks': [],
Expand All @@ -776,7 +775,7 @@ async function createComfyConfigFile(userSettingsPath: string): Promise<void> {
}

try {
await fsPromises.writeFile(configFilePath, JSON.stringify(configContent, null, 2));
fs.writeFileSync(configFilePath, JSON.stringify(configContent, null, 2));
log.info(`Created ComfyUI config file at: ${configFilePath}`);
} catch (error) {
log.error(`Failed to create ComfyUI config file: ${error}`);
Expand Down Expand Up @@ -861,17 +860,13 @@ async function determineResourcesPaths(): Promise<{
}

const defaultUserResourcesPath = getDefaultUserResourcesPath();
const defaultPythonInstallPath =
process.platform === 'win32'
? path.join(path.dirname(path.dirname(app.getPath('userData'))), 'Local', 'comfyui_electron')
: app.getPath('userData');

const appResourcePath = process.resourcesPath;

// TODO(robinhuang): Look for extra models yaml file and use that as the userResourcesPath if it exists.
return {
userResourcesPath: defaultUserResourcesPath,
pythonInstallPath: defaultPythonInstallPath,
pythonInstallPath: basePath,
appResourcesPath: appResourcePath,
modelConfigPath: modelConfigPath,
basePath: basePath,
Expand Down

0 comments on commit 2faf6eb

Please sign in to comment.