mirror of
https://github.com/actions/setup-python.git
synced 2025-12-09 06:05:19 +00:00
Merge 654686df1fb48b4b1b575e0e6d4cb01ba99b8f96 into 83679a892e2d95755f2dac6acb0bfd1e9ac5d548
This commit is contained in:
commit
dcc04a7206
@ -307,6 +307,32 @@ describe('findPyPyVersion', () => {
|
||||
).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 () => {
|
||||
spyCacheDir = jest.spyOn(tc, 'cacheDir');
|
||||
spyCacheDir.mockImplementation(() =>
|
||||
|
||||
@ -6,6 +6,8 @@ import * as semver from 'semver';
|
||||
import * as core from '@actions/core';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
|
||||
import {addPkgConfigPathToEnv} from './utils';
|
||||
|
||||
export async function findGraalPyVersion(
|
||||
versionSpec: string,
|
||||
architecture: string,
|
||||
@ -67,7 +69,7 @@ export async function findGraalPyVersion(
|
||||
core.exportVariable('Python2_ROOT_DIR', installDir);
|
||||
// https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3
|
||||
core.exportVariable('Python3_ROOT_DIR', installDir);
|
||||
core.exportVariable('PKG_CONFIG_PATH', pythonLocation + '/lib/pkgconfig');
|
||||
addPkgConfigPathToEnv(pythonLocation + '/lib/pkgconfig');
|
||||
core.addPath(pythonLocation);
|
||||
core.addPath(_binDir);
|
||||
}
|
||||
|
||||
@ -8,7 +8,8 @@ import {
|
||||
readExactPyPyVersionFile,
|
||||
validatePythonVersionFormatForPyPy,
|
||||
IPyPyManifestRelease,
|
||||
getBinaryDirectory
|
||||
getBinaryDirectory,
|
||||
addPkgConfigPathToEnv
|
||||
} from './utils';
|
||||
|
||||
import * as semver from 'semver';
|
||||
@ -92,7 +93,8 @@ export async function findPyPyVersion(
|
||||
core.exportVariable('Python2_ROOT_DIR', installDir);
|
||||
// https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3
|
||||
core.exportVariable('Python3_ROOT_DIR', installDir);
|
||||
core.exportVariable('PKG_CONFIG_PATH', pythonLocation + '/lib/pkgconfig');
|
||||
addPkgConfigPathToEnv(pythonLocation + '/lib/pkgconfig');
|
||||
|
||||
core.addPath(pythonLocation);
|
||||
core.addPath(_binDir);
|
||||
}
|
||||
|
||||
@ -10,6 +10,8 @@ import * as core from '@actions/core';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
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.
|
||||
// This is where pip is, along with anything that pip installs.
|
||||
// There is a separate directory for `pip install --user`.
|
||||
@ -150,7 +152,6 @@ export async function useCpythonVersion(
|
||||
);
|
||||
if (updateEnvironment) {
|
||||
core.exportVariable('pythonLocation', installDir);
|
||||
core.exportVariable('PKG_CONFIG_PATH', installDir + '/lib/pkgconfig');
|
||||
core.exportVariable('pythonLocation', installDir);
|
||||
// https://cmake.org/cmake/help/latest/module/FindPython.html#module:FindPython
|
||||
core.exportVariable('Python_ROOT_DIR', installDir);
|
||||
@ -158,7 +159,8 @@ export async function useCpythonVersion(
|
||||
core.exportVariable('Python2_ROOT_DIR', installDir);
|
||||
// https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3
|
||||
core.exportVariable('Python3_ROOT_DIR', installDir);
|
||||
core.exportVariable('PKG_CONFIG_PATH', installDir + '/lib/pkgconfig');
|
||||
|
||||
addPkgConfigPathToEnv(installDir + '/lib/pkgconfig');
|
||||
|
||||
if (IS_LINUX) {
|
||||
const libPath = process.env.LD_LIBRARY_PATH
|
||||
|
||||
10
src/utils.ts
10
src/utils.ts
@ -422,3 +422,13 @@ export function getDownloadFileName(downloadUrl: string): string | undefined {
|
||||
? path.join(tempDir, path.basename(downloadUrl))
|
||||
: undefined;
|
||||
}
|
||||
|
||||
export function addPkgConfigPathToEnv(new_path: string): undefined {
|
||||
const pkg_config_path = process.env['PKG_CONFIG_PATH'];
|
||||
|
||||
if (pkg_config_path === undefined) {
|
||||
core.exportVariable('PKG_CONFIG_PATH', new_path);
|
||||
} else {
|
||||
core.exportVariable('PKG_CONFIG_PATH', `${pkg_config_path}${path.delimiter}${new_path}`);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user