From f4849a2e716047d053bec98d7cfdd81e6ea5dfa7 Mon Sep 17 00:00:00 2001 From: wep21 Date: Sun, 28 Apr 2024 13:53:56 +0900 Subject: [PATCH 1/7] add break system packages option into pip command Signed-off-by: wep21 --- dist/index.js | 9 +++++++++ src/package_manager/pip.ts | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/dist/index.js b/dist/index.js index c74f37081..41c745cd2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -7033,6 +7033,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 +7056,11 @@ function runPython3PipInstall(packages, run_with_sudo = true) { cwd: path.sep, }; if (run_with_sudo) { + utils.exec("sudo", pip3ConfigCommandLine); return utils.exec("sudo", pip3CommandLine.concat(packages), options); } else { + utils.exec(pip3ConfigCommandLine[0], pip3ConfigCommandLine.splice(1)); return utils.exec(args[0], args.splice(1), options); } }); diff --git a/src/package_manager/pip.ts b/src/package_manager/pip.ts index c4d1c7be2..8fbde8f60 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) { + utils.exec("sudo", pip3ConfigCommandLine); return utils.exec("sudo", pip3CommandLine.concat(packages), options); } else { + utils.exec(pip3ConfigCommandLine[0], pip3ConfigCommandLine.splice(1)); return utils.exec(args[0], args.splice(1), options); } } From 4344279b0167515e0da95f08bd5d0c5c2ea4eb02 Mon Sep 17 00:00:00 2001 From: wep21 Date: Sun, 28 Apr 2024 14:20:14 +0900 Subject: [PATCH 2/7] test Signed-off-by: wep21 --- dist/index.js | 2 +- src/package_manager/pip.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 41c745cd2..b102d227e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -7030,7 +7030,7 @@ const pip3Packages = [ "pytest-repeat", "pytest-rerunfailures", "pytest-runner", - "setuptools<60.0", + "setuptools", "wheel", ]; const pip3ConfigCommandLine = [ diff --git a/src/package_manager/pip.ts b/src/package_manager/pip.ts index 8fbde8f60..f3ce4e09c 100644 --- a/src/package_manager/pip.ts +++ b/src/package_manager/pip.ts @@ -57,7 +57,7 @@ const pip3Packages: string[] = [ "pytest-repeat", "pytest-rerunfailures", "pytest-runner", - "setuptools<60.0", + "setuptools", "wheel", ]; From 96bcc257623b71a072d8ba3acf03654fe7c55e7c Mon Sep 17 00:00:00 2001 From: Daisuke Nishimatsu <42202095+wep21@users.noreply.github.com> Date: Mon, 29 Apr 2024 10:12:33 +0900 Subject: [PATCH 3/7] add await Co-authored-by: Christophe Bedard Signed-off-by: wep21 --- src/package_manager/pip.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/package_manager/pip.ts b/src/package_manager/pip.ts index f3ce4e09c..f9e96463e 100644 --- a/src/package_manager/pip.ts +++ b/src/package_manager/pip.ts @@ -87,7 +87,7 @@ export async function runPython3PipInstall( cwd: path.sep, }; if (run_with_sudo) { - utils.exec("sudo", pip3ConfigCommandLine); + await utils.exec("sudo", pip3ConfigCommandLine); return utils.exec("sudo", pip3CommandLine.concat(packages), options); } else { utils.exec(pip3ConfigCommandLine[0], pip3ConfigCommandLine.splice(1)); From efd9003b8c419d3492bd474ad850d154d2461602 Mon Sep 17 00:00:00 2001 From: Daisuke Nishimatsu <42202095+wep21@users.noreply.github.com> Date: Mon, 29 Apr 2024 10:12:43 +0900 Subject: [PATCH 4/7] add await Co-authored-by: Christophe Bedard Signed-off-by: wep21 --- src/package_manager/pip.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/package_manager/pip.ts b/src/package_manager/pip.ts index f9e96463e..e5e03625c 100644 --- a/src/package_manager/pip.ts +++ b/src/package_manager/pip.ts @@ -90,7 +90,7 @@ export async function runPython3PipInstall( await utils.exec("sudo", pip3ConfigCommandLine); return utils.exec("sudo", pip3CommandLine.concat(packages), options); } else { - utils.exec(pip3ConfigCommandLine[0], pip3ConfigCommandLine.splice(1)); + await utils.exec(pip3ConfigCommandLine[0], pip3ConfigCommandLine.splice(1)); return utils.exec(args[0], args.splice(1), options); } } From 04dc2bacd2e2e0e7c1bd0b507f9630da90850fb8 Mon Sep 17 00:00:00 2001 From: wep21 Date: Tue, 30 Apr 2024 00:51:57 +0900 Subject: [PATCH 5/7] build Signed-off-by: wep21 --- dist/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index b102d227e..9ddfb96b2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -7056,11 +7056,11 @@ function runPython3PipInstall(packages, run_with_sudo = true) { cwd: path.sep, }; if (run_with_sudo) { - utils.exec("sudo", pip3ConfigCommandLine); + yield utils.exec("sudo", pip3ConfigCommandLine); return utils.exec("sudo", pip3CommandLine.concat(packages), options); } else { - utils.exec(pip3ConfigCommandLine[0], pip3ConfigCommandLine.splice(1)); + yield utils.exec(pip3ConfigCommandLine[0], pip3ConfigCommandLine.splice(1)); return utils.exec(args[0], args.splice(1), options); } }); From e024e71a6a19d3c700ba914eb8031a1ea6d3aae5 Mon Sep 17 00:00:00 2001 From: wep21 Date: Tue, 30 Apr 2024 01:13:32 +0900 Subject: [PATCH 6/7] Revert "test" This reverts commit 4344279b0167515e0da95f08bd5d0c5c2ea4eb02. Signed-off-by: wep21 --- dist/index.js | 2 +- src/package_manager/pip.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 9ddfb96b2..c6aa5c6b9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -7030,7 +7030,7 @@ const pip3Packages = [ "pytest-repeat", "pytest-rerunfailures", "pytest-runner", - "setuptools", + "setuptools<60.0", "wheel", ]; const pip3ConfigCommandLine = [ diff --git a/src/package_manager/pip.ts b/src/package_manager/pip.ts index e5e03625c..a19afd48c 100644 --- a/src/package_manager/pip.ts +++ b/src/package_manager/pip.ts @@ -57,7 +57,7 @@ const pip3Packages: string[] = [ "pytest-repeat", "pytest-rerunfailures", "pytest-runner", - "setuptools", + "setuptools<60.0", "wheel", ]; From 913fb87c73c319a4f64f3700a3ad067a28a166ce Mon Sep 17 00:00:00 2001 From: wep21 Date: Tue, 30 Apr 2024 03:03:29 +0900 Subject: [PATCH 7/7] link python3.10 for osx Signed-off-by: wep21 --- dist/index.js | 30 +++++++++++++++++++++++++++++- src/package_manager/brew.ts | 25 +++++++++++++++++++++++++ src/setup-ros-osx.ts | 1 + 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/dist/index.js b/dist/index.js index c6aa5c6b9..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; /***/ }), @@ -7356,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/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",