FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Extend PKG_CONFIG path rather than setting it by chrhansk · Pull Request #1242 · actions/setup-python · GitHub

Repository navigation

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

Filter by extension

Filter by extension .ts  (5) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
26 changes: 26 additions & 0 deletions __tests__/find-pypy.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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(() =>
Expand Down
4 changes: 3 additions & 1 deletion src/find-graalpy.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 4 additions & 2 deletions src/find-pypy.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
readExactPyPyVersionFile,
validatePythonVersionFormatForPyPy,
IPyPyManifestRelease,
getBinaryDirectory
getBinaryDirectory,
addPkgConfigPathToEnv
} from './utils';

import * as semver from 'semver';
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 4 additions & 2 deletions src/find-python.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -150,15 +152,15 @@ 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);
// https://cmake.org/cmake/help/latest/module/FindPython2.html#module:FindPython2
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
Expand Down
10 changes: 10 additions & 0 deletions src/utils.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
}

Back | FazBrowse Home | New Git URL