From 2d0a61e68992e1abc04350660958934bd213e493 Mon Sep 17 00:00:00 2001 From: Delphine Roux Date: Tue, 18 Apr 2023 21:32:06 -0700 Subject: [PATCH 1/2] add mac case for setting LD_LIBRARY_PATH --- src/install-python.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/install-python.ts b/src/install-python.ts index 2af61291d..d59fd9483 100644 --- a/src/install-python.ts +++ b/src/install-python.ts @@ -49,6 +49,7 @@ async function installPython(workingDirectory: string) { env: { ...process.env, ...(IS_LINUX && {LD_LIBRARY_PATH: path.join(workingDirectory, 'lib')}) + ...(IS_MAC && {LD_LIBRARY_PATH: path.join('$(brew --prefix)', 'lib')}) }, silent: true, listeners: { From ae1c03fc742abfc2a8aa9368fd9fef0c369f707d Mon Sep 17 00:00:00 2001 From: Delphine Roux Date: Tue, 18 Apr 2023 21:49:48 -0700 Subject: [PATCH 2/2] add function to set brew path accordingly in LD_LIBRARY_PATH for macOS --- src/install-python.ts | 5 +++-- src/utils.ts | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/install-python.ts b/src/install-python.ts index d59fd9483..6cefe50a8 100644 --- a/src/install-python.ts +++ b/src/install-python.ts @@ -3,7 +3,7 @@ import * as core from '@actions/core'; import * as tc from '@actions/tool-cache'; import * as exec from '@actions/exec'; import {ExecOptions} from '@actions/exec/lib/interfaces'; -import {IS_WINDOWS, IS_LINUX} from './utils'; +import {IS_WINDOWS, IS_LINUX, IS_MAC, getMacOSBrewPath} from './utils'; const TOKEN = core.getInput('token'); const AUTH = !TOKEN ? undefined : `token ${TOKEN}`; @@ -44,12 +44,13 @@ export function getManifest(): Promise { } async function installPython(workingDirectory: string) { + const brewPath = await getMacOSBrewPath(); const options: ExecOptions = { cwd: workingDirectory, env: { ...process.env, ...(IS_LINUX && {LD_LIBRARY_PATH: path.join(workingDirectory, 'lib')}) - ...(IS_MAC && {LD_LIBRARY_PATH: path.join('$(brew --prefix)', 'lib')}) + ...(IS_MAC && {LD_LIBRARY_PATH: path.join(brewPath, 'lib')}) }, silent: true, listeners: { diff --git a/src/utils.ts b/src/utils.ts index 5a5866eae..806953acc 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -152,6 +152,16 @@ async function getMacOSInfo() { return {osName: 'macOS', osVersion: macOSVersion}; } +export async function getMacOSBrewPath() { + const {stdout} = await exec.getExecOutput('brew', ['--prefix'], { + silent: true + }); + + const brewPath = stdout.trim(); + + return {brewPath: brewPath}; +} + export async function getLinuxInfo() { const {stdout} = await exec.getExecOutput('lsb_release', ['-i', '-r', '-s'], { silent: true