Skip to content

Commit

Permalink
Extend LIBRARY_PATH as well as LD_LIBRARY_PATH on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
tyrken committed Jul 12, 2024
1 parent 39cd149 commit 36977c0
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/find-python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,11 @@ export async function useCpythonVersion(
core.exportVariable('PKG_CONFIG_PATH', installDir + '/lib/pkgconfig');

if (IS_LINUX) {
const libPath = process.env.LD_LIBRARY_PATH
? `:${process.env.LD_LIBRARY_PATH}`
: '';
const pyLibPath = path.join(installDir, 'lib');

if (!libPath.split(':').includes(pyLibPath)) {
core.exportVariable('LD_LIBRARY_PATH', pyLibPath + libPath);
}
ensurePathInEnvVar('LIBRARY_PATH', pyLibPath);
ensurePathInEnvVar('LD_LIBRARY_PATH', pyLibPath);
}

core.addPath(installDir);
core.addPath(_binDir);

Expand Down Expand Up @@ -159,6 +155,17 @@ export async function useCpythonVersion(
return {impl: 'CPython', version: installed};
}

/** Ensure a folder is present in a colon-separated env-var */
function ensurePathInEnvVar(envVarName: string, extraPath: string) {
const currentPath = process.env[envVarName]
? `:${process.env[envVarName]}`
: '';

if (!currentPath.split(':').includes(extraPath)) {
core.exportVariable(envVarName, extraPath + currentPath);
}
}

/** Convert versions like `3.8-dev` to a version like `~3.8.0-0`. */
function desugarDevVersion(versionSpec: string) {
const devVersion = /^(\d+)\.(\d+)-dev$/;
Expand Down

0 comments on commit 36977c0

Please sign in to comment.