Skip to content

Commit 1c9306a

Browse files
committed
Extend PKG_CONFIG path rather than setting it
1 parent cfd55ca commit 1c9306a

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

src/find-graalpy.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import * as semver from 'semver';
66
import * as core from '@actions/core';
77
import * as tc from '@actions/tool-cache';
88

9+
import {
10+
addPkgConfigPathToEnv
11+
} from './utils';
12+
913
export async function findGraalPyVersion(
1014
versionSpec: string,
1115
architecture: string,
@@ -67,7 +71,7 @@ export async function findGraalPyVersion(
6771
core.exportVariable('Python2_ROOT_DIR', installDir);
6872
// https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3
6973
core.exportVariable('Python3_ROOT_DIR', installDir);
70-
core.exportVariable('PKG_CONFIG_PATH', pythonLocation + '/lib/pkgconfig');
74+
addPkgConfigPathToEnv(pythonLocation + '/lib/pkgconfig');
7175
core.addPath(pythonLocation);
7276
core.addPath(_binDir);
7377
}

src/find-pypy.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import {
88
readExactPyPyVersionFile,
99
validatePythonVersionFormatForPyPy,
1010
IPyPyManifestRelease,
11-
getBinaryDirectory
11+
getBinaryDirectory,
12+
addPkgConfigPathToEnv
1213
} from './utils';
1314

1415
import * as semver from 'semver';
@@ -92,7 +93,8 @@ export async function findPyPyVersion(
9293
core.exportVariable('Python2_ROOT_DIR', installDir);
9394
// https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3
9495
core.exportVariable('Python3_ROOT_DIR', installDir);
95-
core.exportVariable('PKG_CONFIG_PATH', pythonLocation + '/lib/pkgconfig');
96+
addPkgConfigPathToEnv(pythonLocation + '/lib/pkgconfig');
97+
9698
core.addPath(pythonLocation);
9799
core.addPath(_binDir);
98100
}

src/find-python.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import * as core from '@actions/core';
1010
import * as tc from '@actions/tool-cache';
1111
import * as exec from '@actions/exec';
1212

13+
import {
14+
addPkgConfigPathToEnv
15+
} from './utils';
16+
1317
// Python has "scripts" or "bin" directories where command-line tools that come with packages are installed.
1418
// This is where pip is, along with anything that pip installs.
1519
// There is a separate directory for `pip install --user`.
@@ -150,15 +154,15 @@ export async function useCpythonVersion(
150154
);
151155
if (updateEnvironment) {
152156
core.exportVariable('pythonLocation', installDir);
153-
core.exportVariable('PKG_CONFIG_PATH', installDir + '/lib/pkgconfig');
154157
core.exportVariable('pythonLocation', installDir);
155158
// https://cmake.org/cmake/help/latest/module/FindPython.html#module:FindPython
156159
core.exportVariable('Python_ROOT_DIR', installDir);
157160
// https://cmake.org/cmake/help/latest/module/FindPython2.html#module:FindPython2
158161
core.exportVariable('Python2_ROOT_DIR', installDir);
159162
// https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3
160163
core.exportVariable('Python3_ROOT_DIR', installDir);
161-
core.exportVariable('PKG_CONFIG_PATH', installDir + '/lib/pkgconfig');
164+
165+
addPkgConfigPathToEnv(installDir + '/lib/pkgconfig');
162166

163167
if (IS_LINUX) {
164168
const libPath = process.env.LD_LIBRARY_PATH

src/utils.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,3 +422,18 @@ export function getDownloadFileName(downloadUrl: string): string | undefined {
422422
? path.join(tempDir, path.basename(downloadUrl))
423423
: undefined;
424424
}
425+
426+
427+
export function addPkgConfigPathToEnv(path: string): undefined {
428+
const pkg_config_path = process.env["PKG_CONFIG_PATH"];
429+
430+
if (pkg_config_path === undefined) {
431+
core.exportVariable('PKG_CONFIG_PATH', path);
432+
} else {
433+
if(IS_WINDOWS) {
434+
core.exportVariable('PKG_CONFIG_PATH', `${path};${pkg_config_path}`);
435+
} else {
436+
core.exportVariable('PKG_CONFIG_PATH', `${path}:${pkg_config_path}`);
437+
}
438+
}
439+
}

0 commit comments

Comments
 (0)