Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91070,13 +91070,9 @@ function useCpythonVersion(version, architecture, updateEnvironment, checkLatest
core.exportVariable('Python3_ROOT_DIR', installDir);
core.exportVariable('PKG_CONFIG_PATH', installDir + '/lib/pkgconfig');
if (utils_1.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);
Copy link

@jaswanthikolla jaswanthikolla Jul 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH, I wouldn't go with the route of LD_LIBRARY_PATH as some systems ( including containers) doesn't allow it as it's a security issue.

ensurePathInEnvVar('LD_LIBRARY_PATH', pyLibPath);
}
core.addPath(installDir);
core.addPath(_binDir);
Expand All @@ -91099,6 +91095,15 @@ function useCpythonVersion(version, architecture, updateEnvironment, checkLatest
});
}
exports.useCpythonVersion = useCpythonVersion;
/** Ensure a folder is present in a colon-separated env-var */
function ensurePathInEnvVar(envVarName, extraPath) {
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) {
const devVersion = /^(\d+)\.(\d+)-dev$/;
Expand Down
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