Skip to content

Commit

Permalink
fix: modify macos ci (#675)
Browse files Browse the repository at this point in the history
Signed-off-by: wep21 <daisuke.nishimatsu1021@gmail.com>
  • Loading branch information
wep21 authored Apr 30, 2024
1 parent cfa8b33 commit 1692fc1
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.
39 changes: 38 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6752,7 +6752,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.installBrewDependencies = exports.runBrew = void 0;
exports.setupPython = exports.installBrewDependencies = exports.runBrew = void 0;
const utils = __importStar(__nccwpck_require__(1314));
const brewDependencies = [
"asio",
Expand Down Expand Up @@ -6801,6 +6801,33 @@ function installBrewDependencies() {
});
}
exports.installBrewDependencies = installBrewDependencies;
/**
* Set python path to pin specific python.
*
* @returns Promise<number> exit code
*/
function setupPython() {
return __awaiter(this, void 0, void 0, function* () {
yield utils.exec("find", [
"/usr/local/bin",
"-lname",
"'*/Library/Frameworks/Python.framework/*'",
"-delete",
]);
yield utils.exec("sudo", [
"rm",
"-rf",
"/Library/Frameworks/Python.framework/",
]);
yield utils.exec("brew", ["unlink", "python"]);
return utils.exec("ln", [
"-s",
"/opt/homebrew/bin/pip3.10",
"/opt/homebrew/bin/pip3",
]);
});
}
exports.setupPython = setupPython;


/***/ }),
Expand Down Expand Up @@ -7033,6 +7060,13 @@ const pip3Packages = [
"setuptools<60.0",
"wheel",
];
const pip3ConfigCommandLine = [
"pip3",
"config",
"set",
"global.break-system-packages",
"true",
];
const pip3CommandLine = ["pip3", "install", "--upgrade"];
/**
* Run Python3 pip install on a list of specified packages.
Expand All @@ -7049,9 +7083,11 @@ function runPython3PipInstall(packages, run_with_sudo = true) {
cwd: path.sep,
};
if (run_with_sudo) {
yield utils.exec("sudo", pip3ConfigCommandLine);
return utils.exec("sudo", pip3CommandLine.concat(packages), options);
}
else {
yield utils.exec(pip3ConfigCommandLine[0], pip3ConfigCommandLine.splice(1));
return utils.exec(args[0], args.splice(1), options);
}
});
Expand Down Expand Up @@ -7347,6 +7383,7 @@ const pip = __importStar(__nccwpck_require__(6744));
function runOsX() {
return __awaiter(this, void 0, void 0, function* () {
yield brew.installBrewDependencies();
yield brew.setupPython();
yield utils.exec("sudo", [
"bash",
"-c",
Expand Down
25 changes: 25 additions & 0 deletions src/package_manager/brew.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,28 @@ export async function runBrew(packages: string[]): Promise<number> {
export async function installBrewDependencies(): Promise<number> {
return runBrew(brewDependencies);
}

/**
* Set python path to pin specific python.
*
* @returns Promise<number> exit code
*/
export async function setupPython(): Promise<number> {
await utils.exec("find", [
"/usr/local/bin",
"-lname",
"'*/Library/Frameworks/Python.framework/*'",
"-delete",
]);
await utils.exec("sudo", [
"rm",
"-rf",
"/Library/Frameworks/Python.framework/",
]);
await utils.exec("brew", ["unlink", "python"]);
return utils.exec("ln", [
"-s",
"/opt/homebrew/bin/pip3.10",
"/opt/homebrew/bin/pip3",
]);
}
9 changes: 9 additions & 0 deletions src/package_manager/pip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ const pip3Packages: string[] = [
"wheel",
];

const pip3ConfigCommandLine: string[] = [
"pip3",
"config",
"set",
"global.break-system-packages",
"true",
];
const pip3CommandLine: string[] = ["pip3", "install", "--upgrade"];

/**
Expand All @@ -80,8 +87,10 @@ export async function runPython3PipInstall(
cwd: path.sep,
};
if (run_with_sudo) {
await utils.exec("sudo", pip3ConfigCommandLine);
return utils.exec("sudo", pip3CommandLine.concat(packages), options);
} else {
await utils.exec(pip3ConfigCommandLine[0], pip3ConfigCommandLine.splice(1));
return utils.exec(args[0], args.splice(1), options);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/setup-ros-osx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as pip from "./package_manager/pip";
*/
export async function runOsX() {
await brew.installBrewDependencies();
await brew.setupPython();
await utils.exec("sudo", [
"bash",
"-c",
Expand Down

0 comments on commit 1692fc1

Please # to comment.