Skip to content

Defining triple for sidecar in CI/CD on intel mac #3548

@flusterIO

Description

@flusterIO

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    🪵 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions