Skip to content

Commit 36977c0

Browse files
committed
Extend LIBRARY_PATH as well as LD_LIBRARY_PATH on Linux
1 parent 39cd149 commit 36977c0

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/find-python.ts

+14-7
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,11 @@ export async function useCpythonVersion(
121121
core.exportVariable('PKG_CONFIG_PATH', installDir + '/lib/pkgconfig');
122122

123123
if (IS_LINUX) {
124-
const libPath = process.env.LD_LIBRARY_PATH
125-
? `:${process.env.LD_LIBRARY_PATH}`
126-
: '';
127124
const pyLibPath = path.join(installDir, 'lib');
128-
129-
if (!libPath.split(':').includes(pyLibPath)) {
130-
core.exportVariable('LD_LIBRARY_PATH', pyLibPath + libPath);
131-
}
125+
ensurePathInEnvVar('LIBRARY_PATH', pyLibPath);
126+
ensurePathInEnvVar('LD_LIBRARY_PATH', pyLibPath);
132127
}
128+
133129
core.addPath(installDir);
134130
core.addPath(_binDir);
135131

@@ -159,6 +155,17 @@ export async function useCpythonVersion(
159155
return {impl: 'CPython', version: installed};
160156
}
161157

158+
/** Ensure a folder is present in a colon-separated env-var */
159+
function ensurePathInEnvVar(envVarName: string, extraPath: string) {
160+
const currentPath = process.env[envVarName]
161+
? `:${process.env[envVarName]}`
162+
: '';
163+
164+
if (!currentPath.split(':').includes(extraPath)) {
165+
core.exportVariable(envVarName, extraPath + currentPath);
166+
}
167+
}
168+
162169
/** Convert versions like `3.8-dev` to a version like `~3.8.0-0`. */
163170
function desugarDevVersion(versionSpec: string) {
164171
const devVersion = /^(\d+)\.(\d+)-dev$/;

0 commit comments

Comments
 (0)