From 1692fc1748454251d8aa625a490be6d8a85d77cf Mon Sep 17 00:00:00 2001 From: Daisuke Nishimatsu <42202095+wep21@users.noreply.github.com> Date: Tue, 30 Apr 2024 14:30:58 +0900 Subject: [PATCH] fix: modify macos ci (#675) Signed-off-by: wep21 --- dist/index.js | 39 ++++++++++++++++++++++++++++++++++++- src/package_manager/brew.ts | 25 ++++++++++++++++++++++++ src/package_manager/pip.ts | 9 +++++++++ src/setup-ros-osx.ts | 1 + 4 files changed, 73 insertions(+), 1 deletion(-) diff --git a/dist/index.js b/dist/index.js index c74f37081..b5bef75ed 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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", @@ -6801,6 +6801,33 @@ function installBrewDependencies() { }); } exports.installBrewDependencies = installBrewDependencies; +/** + * Set python path to pin specific python. + * + * @returns Promise 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; /***/ }), @@ -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. @@ -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); } }); @@ -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", diff --git a/src/package_manager/brew.ts b/src/package_manager/brew.ts index ed5541bba..e0ad570d5 100644 --- a/src/package_manager/brew.ts +++ b/src/package_manager/brew.ts @@ -43,3 +43,28 @@ export async function runBrew(packages: string[]): Promise { export async function installBrewDependencies(): Promise { return runBrew(brewDependencies); } + +/** + * Set python path to pin specific python. + * + * @returns Promise exit code + */ +export async function setupPython(): Promise { + 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", + ]); +} diff --git a/src/package_manager/pip.ts b/src/package_manager/pip.ts index c4d1c7be2..a19afd48c 100644 --- a/src/package_manager/pip.ts +++ b/src/package_manager/pip.ts @@ -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"]; /** @@ -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); } } diff --git a/src/setup-ros-osx.ts b/src/setup-ros-osx.ts index bd1e22407..d84623d45 100644 --- a/src/setup-ros-osx.ts +++ b/src/setup-ros-osx.ts @@ -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",