mirror of
https://github.com/actions/setup-python.git
synced 2025-12-10 22:55:20 +00:00
Extend PKG_CONFIG path rather than overwriting it
This commit is contained in:
parent
cfd55ca824
commit
87c35f43f0
@ -307,6 +307,32 @@ describe('findPyPyVersion', () => {
|
|||||||
).rejects.toThrow();
|
).rejects.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('update PKG_CONFIG_PATH', async () => {
|
||||||
|
process.env['PKG_CONFIG_PATH'] = '/test/dir';
|
||||||
|
spyCacheDir = jest.spyOn(tc, 'cacheDir');
|
||||||
|
spyCacheDir.mockImplementation(() =>
|
||||||
|
path.join(toolDir, 'PyPy', '3.7.7', architecture)
|
||||||
|
);
|
||||||
|
spyChmodSync = jest.spyOn(fs, 'chmodSync');
|
||||||
|
spyChmodSync.mockImplementation(() => undefined);
|
||||||
|
await expect(
|
||||||
|
finder.findPyPyVersion(
|
||||||
|
'pypy-3.7-v7.3.x',
|
||||||
|
architecture,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
).resolves.toEqual({
|
||||||
|
resolvedPythonVersion: '3.7.9',
|
||||||
|
resolvedPyPyVersion: '7.3.3'
|
||||||
|
});
|
||||||
|
expect(spyCoreExportVariable).toHaveBeenCalledWith(
|
||||||
|
'PKG_CONFIG_PATH',
|
||||||
|
expect.stringContaining('/test/dir')
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('found and install successfully', async () => {
|
it('found and install successfully', async () => {
|
||||||
spyCacheDir = jest.spyOn(tc, 'cacheDir');
|
spyCacheDir = jest.spyOn(tc, 'cacheDir');
|
||||||
spyCacheDir.mockImplementation(() =>
|
spyCacheDir.mockImplementation(() =>
|
||||||
|
|||||||
@ -6,6 +6,8 @@ import * as semver from 'semver';
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
|
|
||||||
|
import {addPkgConfigPathToEnv} from './utils';
|
||||||
|
|
||||||
export async function findGraalPyVersion(
|
export async function findGraalPyVersion(
|
||||||
versionSpec: string,
|
versionSpec: string,
|
||||||
architecture: string,
|
architecture: string,
|
||||||
@ -67,7 +69,7 @@ export async function findGraalPyVersion(
|
|||||||
core.exportVariable('Python2_ROOT_DIR', installDir);
|
core.exportVariable('Python2_ROOT_DIR', installDir);
|
||||||
// https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3
|
// https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3
|
||||||
core.exportVariable('Python3_ROOT_DIR', installDir);
|
core.exportVariable('Python3_ROOT_DIR', installDir);
|
||||||
core.exportVariable('PKG_CONFIG_PATH', pythonLocation + '/lib/pkgconfig');
|
addPkgConfigPathToEnv(pythonLocation + '/lib/pkgconfig');
|
||||||
core.addPath(pythonLocation);
|
core.addPath(pythonLocation);
|
||||||
core.addPath(_binDir);
|
core.addPath(_binDir);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,8 @@ import {
|
|||||||
readExactPyPyVersionFile,
|
readExactPyPyVersionFile,
|
||||||
validatePythonVersionFormatForPyPy,
|
validatePythonVersionFormatForPyPy,
|
||||||
IPyPyManifestRelease,
|
IPyPyManifestRelease,
|
||||||
getBinaryDirectory
|
getBinaryDirectory,
|
||||||
|
addPkgConfigPathToEnv
|
||||||
} from './utils';
|
} from './utils';
|
||||||
|
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
@ -92,7 +93,8 @@ export async function findPyPyVersion(
|
|||||||
core.exportVariable('Python2_ROOT_DIR', installDir);
|
core.exportVariable('Python2_ROOT_DIR', installDir);
|
||||||
// https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3
|
// https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3
|
||||||
core.exportVariable('Python3_ROOT_DIR', installDir);
|
core.exportVariable('Python3_ROOT_DIR', installDir);
|
||||||
core.exportVariable('PKG_CONFIG_PATH', pythonLocation + '/lib/pkgconfig');
|
addPkgConfigPathToEnv(pythonLocation + '/lib/pkgconfig');
|
||||||
|
|
||||||
core.addPath(pythonLocation);
|
core.addPath(pythonLocation);
|
||||||
core.addPath(_binDir);
|
core.addPath(_binDir);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import * as core from '@actions/core';
|
|||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
|
|
||||||
|
import {addPkgConfigPathToEnv} from './utils';
|
||||||
|
|
||||||
// Python has "scripts" or "bin" directories where command-line tools that come with packages are installed.
|
// Python has "scripts" or "bin" directories where command-line tools that come with packages are installed.
|
||||||
// This is where pip is, along with anything that pip installs.
|
// This is where pip is, along with anything that pip installs.
|
||||||
// There is a separate directory for `pip install --user`.
|
// There is a separate directory for `pip install --user`.
|
||||||
@ -150,7 +152,6 @@ export async function useCpythonVersion(
|
|||||||
);
|
);
|
||||||
if (updateEnvironment) {
|
if (updateEnvironment) {
|
||||||
core.exportVariable('pythonLocation', installDir);
|
core.exportVariable('pythonLocation', installDir);
|
||||||
core.exportVariable('PKG_CONFIG_PATH', installDir + '/lib/pkgconfig');
|
|
||||||
core.exportVariable('pythonLocation', installDir);
|
core.exportVariable('pythonLocation', installDir);
|
||||||
// https://cmake.org/cmake/help/latest/module/FindPython.html#module:FindPython
|
// https://cmake.org/cmake/help/latest/module/FindPython.html#module:FindPython
|
||||||
core.exportVariable('Python_ROOT_DIR', installDir);
|
core.exportVariable('Python_ROOT_DIR', installDir);
|
||||||
@ -158,7 +159,8 @@ export async function useCpythonVersion(
|
|||||||
core.exportVariable('Python2_ROOT_DIR', installDir);
|
core.exportVariable('Python2_ROOT_DIR', installDir);
|
||||||
// https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3
|
// https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3
|
||||||
core.exportVariable('Python3_ROOT_DIR', installDir);
|
core.exportVariable('Python3_ROOT_DIR', installDir);
|
||||||
core.exportVariable('PKG_CONFIG_PATH', installDir + '/lib/pkgconfig');
|
|
||||||
|
addPkgConfigPathToEnv(installDir + '/lib/pkgconfig');
|
||||||
|
|
||||||
if (IS_LINUX) {
|
if (IS_LINUX) {
|
||||||
const libPath = process.env.LD_LIBRARY_PATH
|
const libPath = process.env.LD_LIBRARY_PATH
|
||||||
|
|||||||
14
src/utils.ts
14
src/utils.ts
@ -422,3 +422,17 @@ export function getDownloadFileName(downloadUrl: string): string | undefined {
|
|||||||
? path.join(tempDir, path.basename(downloadUrl))
|
? path.join(tempDir, path.basename(downloadUrl))
|
||||||
: undefined;
|
: undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function addPkgConfigPathToEnv(path: string): undefined {
|
||||||
|
const pkg_config_path = process.env['PKG_CONFIG_PATH'];
|
||||||
|
|
||||||
|
if (pkg_config_path === undefined) {
|
||||||
|
core.exportVariable('PKG_CONFIG_PATH', path);
|
||||||
|
} else {
|
||||||
|
if (IS_WINDOWS) {
|
||||||
|
core.exportVariable('PKG_CONFIG_PATH', `${path};${pkg_config_path}`);
|
||||||
|
} else {
|
||||||
|
core.exportVariable('PKG_CONFIG_PATH', `${path}:${pkg_config_path}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user