-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Download binaries from github releases
- Loading branch information
Showing
4 changed files
with
71 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env node | ||
|
||
const packageJson = require('./package.json'); | ||
|
||
// Local developement. | ||
if (packageJson.version === '0.0.1-dev') | ||
process.exit(0); | ||
|
||
const fs = require('node:fs'); | ||
const zlib = require('node:zlib'); | ||
const {pipeline} = require('node:stream/promises'); | ||
|
||
const urlPrefix = 'https://github.com/frost-beta/executorch.js/releases/download'; | ||
|
||
main().catch((error) => { | ||
console.error('Error downloading node-mlx:', error); | ||
process.exit(1); | ||
}); | ||
|
||
async function main() { | ||
const dir = `${__dirname}/build/Release`; | ||
fs.mkdirSync(dir, {recursive: true}); | ||
|
||
const os = {darwin: 'mac', win32: 'win'}[process.platform] ?? process.platform; | ||
const arch = process.arch; | ||
const version = packageJson.version; | ||
|
||
let backend; | ||
if (packageJson.name.includes('-')) | ||
backend = packageJson.name.substring(packageJson.name.lastIndexOf('-') + 1); | ||
else | ||
backend = os == 'mac' ? 'mps' : 'xnnpack'; | ||
|
||
const prefix = `${urlPrefix}/v${version}/executorch-${backend}-${os}-${arch}-release`; | ||
await download(`${prefix}.node.gz`, `${dir}/executorch.node`); | ||
} | ||
|
||
async function download(url, filename) { | ||
const response = await fetch(url); | ||
if (!response.ok) | ||
throw new Error(`Failed to download ${url}, status: ${response.status}`); | ||
|
||
const gunzip = zlib.createGunzip(); | ||
await pipeline(response.body, gunzip, fs.createWriteStream(filename)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters