Defining triple for sidecar in CI/CD on intel mac
Hey, I'm working on fluster and everything was going great until I decided to add a Flask api as a sidecar. Things are working well on all platforms except Intel based macs as the triple isn't being appended properly and the build fails on intel macs telling me that the file with the appended triple cannot be found.
This is what my script looks like:
#!/usr/bin/env node
import fs from 'fs';
import path from 'path';
import { execSync } from "child_process";
console.log("dirName: ", import.meta.dirname)
const sidecarDir = path.join(
import.meta.dirname,
"..",
"apps",
"fluster",
"src-python",
"fluster_sidecar_api"
)
const extension = process.platform === "win32" ? ".exe" : "";
const installScript = `uv sync --directory ${sidecarDir}`
const res = execSync(installScript, {
encoding: "utf-8"
})
console.log(res)
const uvPath = path.join(sidecarDir, ".venv", process.platform === "win32" ? "Scripts" : "bin", `pyinstaller${extension}`);
const compileScript = `${uvPath} --name fluster_python_sidecar --onefile --distpath ${path.join(sidecarDir, "dist")} --workpath ${path.join(sidecarDir, "build")} --specpath ${sidecarDir} ${path.join(sidecarDir, "main.py")}`
const res2 = execSync(compileScript, {
encoding: "utf-8"
})
console.log(res2)
// -- Rename Python Binary --
const existingPath = path.join(
sidecarDir,
"dist",
`fluster_python_sidecar`
);
const rustInfo = execSync("rustc -vV");
const targetTriple = /host: (\S+)/g.exec(rustInfo)[1];
if (!targetTriple) {
console.error("Failed to determine platform target triple");
}
console.log("process.architecture: ", process.architecture)
console.log("process.platform: ", process.platform)
if (process.platform === "darwin" && process.architecture === "x64") {
fs.renameSync(
`${existingPath}${extension}`,
`${existingPath}-x86_64-apple-darwin${extension}`
)
} else {
fs.renameSync(
`${existingPath}${extension}`,
`${existingPath}-${targetTriple}${extension}`
);
}
I had originally copied the 'rename' function directly from the documentation, I've since modified it slightly to the above with no success in either form.
Is there a known issue with this approach in this line in particular?
if (process.platform === "darwin" && process.architecture === "x64") {
For the life of me I can't see why that block is not being executed and the file being renamed.
Thanks in advance!
github's runner nowadays are all arm runners (at least i think the last free intel macs were dropped or are about to be dropped at least) and process.architecture looks at the arch of the node installation, not the system itself which means that this code will always go into the else branch.
With the removal of intel runners we really need to update the example script now...
github's runner nowadays are all arm runners (at least i think the last free intel macs were dropped or are about to be dropped at least) and
process.architecturelooks at the arch of the node installation, not the system itself which means that this code will always go into the else branch.With the removal of intel runners we really need to update the example script now...
Is there some other approach that you can think of? I was aware of the arm/mac issue on Github, but I wasn't sure if the tauri action was doing some magic behind the scenes. Honestly, if one's going to fail I'm all for intel mac being the one that fails, but it'd be nice to be able to support those machines too if it's possible to get the sidecar to work.
If the script would run as a seperate step in the workflow i'd just pipe the --target (or i guess the whole args) into the script. Since it's part of beforeBuildCommand in your project though you can read these env vars in the nodejs script i think - tauri sets that for the beforeBuildCommand so unless wireit clears the env it should work.
i'll move this issue to the docs repo so we can improve the example :)