Skip to content

Commit

Permalink
download UV on github action and build time pick platform
Browse files Browse the repository at this point in the history
  • Loading branch information
KenCorma committed Nov 6, 2024
1 parent f6054e2 commit 1569303
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
14 changes: 14 additions & 0 deletions .github/actions/build/windows/todesktop/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ runs:
shell: cmd
- run: yarn set version --yarn-path self
shell: cmd
- name: Download UV
shell: powershell
run: |
cd ./assets
mkdir uv && mkdir uv/win && mkdir uv/macos && mkdir uv/linux
curl -s https://github.com/astral-sh/uv/releases/download/0.4.30/uv-x86_64-pc-windows-msvc.zip
curl -s https://github.com/astral-sh/uv/releases/download/0.4.30/uv-aarch64-apple-darwin.tar.gz
curl -s https://github.com/astral-sh/uv/releases/download/0.4.30/uv-x86_64-unknown-linux-gnu.tar.gz
tar -xzvf uv-x86_64-pc-windows-msvc.zip
tar -xzvf uv-aarch64-apple-darwin.tar.gz
tar -xzvf uv-x86_64-unknown-linux-gnu.tar.gz
cp -r uv-x86_64-pc-windows-msvc/ uv/win
cp -r uv-aarch64-apple-darwin/ uv/macos
cp -r uv-x86_64-unknown-linux-gnu/ uv/linux
- name: Make app
shell: powershell
env:
Expand Down
Binary file removed assets/uv/uv
Binary file not shown.
Binary file removed assets/uv/uvx
Binary file not shown.
4 changes: 4 additions & 0 deletions scripts/todesktop/afterPack.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ module.exports = async ({ appOutDir, packager, outDir }) => {
const result3 = await fs.rm(path.join(assetPath, "ComfyUI", 'custom_nodes', 'ComfyUI_Manager', ".git"), { recursive: true, force: true });
const result4 = await fs.rm(path.join(assetPath, "ComfyUI", 'custom_nodes', 'DesktopSettingsExtension', ".git"), { recursive: true, force: true });
const result2 = await fs.cp(assetPath, resourcePath, { recursive: true });
await fs.rm(path.join(resourcePath,'uv','win'),{ recursive: true, force: true });
await fs.rm(path.join(resourcePath,'uv','linux'),{ recursive: true, force: true });
}

if (os.platform() === 'win32') {
Expand All @@ -35,5 +37,7 @@ module.exports = async ({ appOutDir, packager, outDir }) => {
const assetPath = path.join(mainPath, 'app-wrapper', 'app', 'assets');
const resourcePath = path.join(path.dirname(appPath), "resources");
await fs.cp(assetPath, resourcePath, { recursive: true });
await fs.rm(path.join(resourcePath,'uv','macos'),{ recursive: true, force: true });
await fs.rm(path.join(resourcePath,'uv','linux'),{ recursive: true, force: true });
}
}
9 changes: 6 additions & 3 deletions src/virtualEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,24 @@ export class VirtualEnvironment {
// Set platform-specific paths
// uv will be in assets/uv on Windows and use the global uv on macOS and Linux
// uv executable is not codesigned, so we need to use the global one on macOS and Linux

const uvFolder = path.join(process.resourcesPath, 'uv');

if (process.platform === 'win32') {
if (app.isPackaged) {
this.uvPath = path.join(app.getAppPath(), 'uv.exe');
this.uvPath = path.join(uvFolder,'win', 'uv.exe');
} else {
this.uvPath = path.join(app.getAppPath(), 'assets', 'uv', 'uv.exe');
}
} else if (process.platform === 'linux') {
if (app.isPackaged) {
this.uvPath = path.join(app.getAppPath(), 'uv.exe');
this.uvPath = path.join(uvFolder,'linux', 'uv');
} else {
this.uvPath = path.join(app.getAppPath(), 'assets', 'uv', 'uv.exe');
}
} else if (process.platform === 'darwin') {
if (app.isPackaged) {
this.uvPath = path.join(process.resourcesPath, 'uv', 'uv');
this.uvPath = path.join(uvFolder,'macos', 'uv');
} else {
//this.uvPath = path.join('uv'); // Use global uv on macOS.
this.uvPath = path.join(app.getAppPath(), 'assets', 'uv', 'uv');
Expand Down
2 changes: 1 addition & 1 deletion todesktop.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"extraResources": [{ "from": "./assets" }],
"filesForDistribution": ["!assets/**", "!dist/**", "!src/**", "!scripts/**", "!.yarn/**", "!.yarnrc.yml"],
"mac": {
"additionalBinariesToSign": ["./assets/uv/uv", "./assets/uv/uvx"]
"additionalBinariesToSign": ["./assets/uv/macos/uv", "./assets/uv/macos/uvx"]
}
}

0 comments on commit 1569303

Please sign in to comment.