mirror of
https://github.com/actions/setup-python.git
synced 2024-11-25 00:20:58 -05:00
Merge pull request #452 from mayeut/fix-env
Remove duplicate code introduced in #440
This commit is contained in:
commit
0ad0f6a0a5
4 changed files with 8 additions and 22 deletions
|
@ -151,8 +151,11 @@ describe('findPyPyVersion', () => {
|
||||||
let spyChmodSync: jest.SpyInstance;
|
let spyChmodSync: jest.SpyInstance;
|
||||||
let spyCoreAddPath: jest.SpyInstance;
|
let spyCoreAddPath: jest.SpyInstance;
|
||||||
let spyCoreExportVariable: jest.SpyInstance;
|
let spyCoreExportVariable: jest.SpyInstance;
|
||||||
|
const env = process.env;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
process.env = {...env};
|
||||||
tcFind = jest.spyOn(tc, 'find');
|
tcFind = jest.spyOn(tc, 'find');
|
||||||
tcFind.mockImplementation((tool: string, version: string) => {
|
tcFind.mockImplementation((tool: string, version: string) => {
|
||||||
const semverRange = new semver.Range(version);
|
const semverRange = new semver.Range(version);
|
||||||
|
@ -214,6 +217,7 @@ describe('findPyPyVersion', () => {
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
jest.restoreAllMocks();
|
jest.restoreAllMocks();
|
||||||
|
process.env = env;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('found PyPy in toolcache', async () => {
|
it('found PyPy in toolcache', async () => {
|
||||||
|
|
|
@ -28,10 +28,12 @@ const manifestData = require('./data/versions-manifest.json');
|
||||||
describe('Finder tests', () => {
|
describe('Finder tests', () => {
|
||||||
let spyCoreAddPath: jest.SpyInstance;
|
let spyCoreAddPath: jest.SpyInstance;
|
||||||
let spyCoreExportVariable: jest.SpyInstance;
|
let spyCoreExportVariable: jest.SpyInstance;
|
||||||
|
const env = process.env;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
process.env = {...env};
|
||||||
spyCoreAddPath = jest.spyOn(core, 'addPath');
|
spyCoreAddPath = jest.spyOn(core, 'addPath');
|
||||||
|
|
||||||
spyCoreExportVariable = jest.spyOn(core, 'exportVariable');
|
spyCoreExportVariable = jest.spyOn(core, 'exportVariable');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -39,6 +41,7 @@ describe('Finder tests', () => {
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
jest.restoreAllMocks();
|
jest.restoreAllMocks();
|
||||||
|
process.env = env;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Finds Python if it is installed', async () => {
|
it('Finds Python if it is installed', async () => {
|
||||||
|
@ -66,7 +69,6 @@ describe('Finder tests', () => {
|
||||||
await finder.useCpythonVersion('3.x', 'x64', false);
|
await finder.useCpythonVersion('3.x', 'x64', false);
|
||||||
expect(spyCoreAddPath).not.toHaveBeenCalled();
|
expect(spyCoreAddPath).not.toHaveBeenCalled();
|
||||||
expect(spyCoreExportVariable).not.toHaveBeenCalled();
|
expect(spyCoreExportVariable).not.toHaveBeenCalled();
|
||||||
expect(spyCoreExportVariable).not.toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Finds stable Python version if it is not installed, but exists in the manifest', async () => {
|
it('Finds stable Python version if it is not installed, but exists in the manifest', async () => {
|
||||||
|
|
9
dist/setup/index.js
vendored
9
dist/setup/index.js
vendored
|
@ -64845,15 +64845,6 @@ function useCpythonVersion(version, architecture, updateEnvironment) {
|
||||||
`The list of all available versions can be found here: ${installer.MANIFEST_URL}`
|
`The list of all available versions can be found here: ${installer.MANIFEST_URL}`
|
||||||
].join(os.EOL));
|
].join(os.EOL));
|
||||||
}
|
}
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const _binDir = binDir(installDir);
|
const _binDir = binDir(installDir);
|
||||||
const binaryExtension = utils_1.IS_WINDOWS ? '.exe' : '';
|
const binaryExtension = utils_1.IS_WINDOWS ? '.exe' : '';
|
||||||
const pythonPath = path.join(utils_1.IS_WINDOWS ? installDir : _binDir, `python${binaryExtension}`);
|
const pythonPath = path.join(utils_1.IS_WINDOWS ? installDir : _binDir, `python${binaryExtension}`);
|
||||||
|
|
|
@ -70,17 +70,6 @@ export async function useCpythonVersion(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const _binDir = binDir(installDir);
|
const _binDir = binDir(installDir);
|
||||||
const binaryExtension = IS_WINDOWS ? '.exe' : '';
|
const binaryExtension = IS_WINDOWS ? '.exe' : '';
|
||||||
const pythonPath = path.join(
|
const pythonPath = path.join(
|
||||||
|
|
Loading…
Reference in a new issue