mirror of
https://github.com/actions/setup-python.git
synced 2025-04-24 15:32:13 +00:00
fix poetry python version
This commit is contained in:
parent
ae11205ec6
commit
70f6f2a532
3 changed files with 37 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as cache from '@actions/cache';
|
import * as cache from '@actions/cache';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
|
import * as io from '@actions/io';
|
||||||
import {getCacheDistributor} from '../src/cache-distributions/cache-factory';
|
import {getCacheDistributor} from '../src/cache-distributions/cache-factory';
|
||||||
|
|
||||||
describe('restore-cache', () => {
|
describe('restore-cache', () => {
|
||||||
|
@ -35,6 +36,9 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
|
||||||
// exec spy
|
// exec spy
|
||||||
let getExecOutputSpy: jest.SpyInstance;
|
let getExecOutputSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
// io spy
|
||||||
|
let whichSpy: jest.SpyInstance;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
process.env['RUNNER_OS'] = process.env['RUNNER_OS'] ?? 'linux';
|
process.env['RUNNER_OS'] = process.env['RUNNER_OS'] ?? 'linux';
|
||||||
|
|
||||||
|
@ -74,6 +78,9 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
|
||||||
return primaryKey;
|
return primaryKey;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
whichSpy = jest.spyOn(io, 'which');
|
||||||
|
whichSpy.mockImplementation(() => '/path/to/python');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Validate provided package manager', () => {
|
describe('Validate provided package manager', () => {
|
||||||
|
|
13
dist/setup/index.js
vendored
13
dist/setup/index.js
vendored
|
@ -38355,8 +38355,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const glob = __importStar(__webpack_require__(281));
|
const glob = __importStar(__webpack_require__(281));
|
||||||
|
const io = __importStar(__webpack_require__(1));
|
||||||
const path = __importStar(__webpack_require__(622));
|
const path = __importStar(__webpack_require__(622));
|
||||||
const exec = __importStar(__webpack_require__(986));
|
const exec = __importStar(__webpack_require__(986));
|
||||||
|
const core = __importStar(__webpack_require__(470));
|
||||||
const cache_distributor_1 = __importDefault(__webpack_require__(596));
|
const cache_distributor_1 = __importDefault(__webpack_require__(596));
|
||||||
class PoetryCache extends cache_distributor_1.default {
|
class PoetryCache extends cache_distributor_1.default {
|
||||||
constructor(pythonVersion, patterns = '**/poetry.lock') {
|
constructor(pythonVersion, patterns = '**/poetry.lock') {
|
||||||
|
@ -38373,6 +38375,17 @@ class PoetryCache extends cache_distributor_1.default {
|
||||||
if (poetryConfig['virtualenvs.in-project'] === true) {
|
if (poetryConfig['virtualenvs.in-project'] === true) {
|
||||||
paths.push(path.join(process.cwd(), '.venv'));
|
paths.push(path.join(process.cwd(), '.venv'));
|
||||||
}
|
}
|
||||||
|
const pythonLocation = yield io.which('python');
|
||||||
|
if (pythonLocation) {
|
||||||
|
core.debug(`pythonLocation is ${pythonLocation}`);
|
||||||
|
const { exitCode, stderr } = yield exec.getExecOutput(`poetry env use ${pythonLocation}`);
|
||||||
|
if (exitCode) {
|
||||||
|
throw new Error(stderr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
core.warning('python binaries were not found in PATH.');
|
||||||
|
}
|
||||||
return paths;
|
return paths;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import * as glob from '@actions/glob';
|
import * as glob from '@actions/glob';
|
||||||
import * as os from 'os';
|
import * as io from '@actions/io';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
import CacheDistributor from './cache-distributor';
|
import CacheDistributor from './cache-distributor';
|
||||||
|
|
||||||
|
@ -28,6 +29,21 @@ class PoetryCache extends CacheDistributor {
|
||||||
paths.push(path.join(process.cwd(), '.venv'));
|
paths.push(path.join(process.cwd(), '.venv'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const pythonLocation = await io.which('python');
|
||||||
|
|
||||||
|
if (pythonLocation) {
|
||||||
|
core.debug(`pythonLocation is ${pythonLocation}`);
|
||||||
|
const {exitCode, stderr} = await exec.getExecOutput(
|
||||||
|
`poetry env use ${pythonLocation}`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (exitCode) {
|
||||||
|
throw new Error(stderr);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
core.warning('python binaries were not found in PATH.');
|
||||||
|
}
|
||||||
|
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue