mirror of
https://github.com/actions/setup-python.git
synced 2025-06-12 15:27:13 +02:00
Fix poetry version (#445)
This commit is contained in:
@ -1,9 +1,11 @@
|
||||
import * as glob from '@actions/glob';
|
||||
import * as os from 'os';
|
||||
import * as io from '@actions/io';
|
||||
import * as path from 'path';
|
||||
import * as exec from '@actions/exec';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import CacheDistributor from './cache-distributor';
|
||||
import {logWarning} from '../utils';
|
||||
|
||||
class PoetryCache extends CacheDistributor {
|
||||
constructor(
|
||||
@ -28,6 +30,26 @@ class PoetryCache extends CacheDistributor {
|
||||
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}`,
|
||||
undefined,
|
||||
{ignoreReturnCode: true}
|
||||
);
|
||||
|
||||
if (exitCode) {
|
||||
logWarning(stderr);
|
||||
}
|
||||
} else {
|
||||
logWarning('python binaries were not found in PATH');
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,12 @@ import * as path from 'path';
|
||||
import * as os from 'os';
|
||||
import fs from 'fs';
|
||||
import {getCacheDistributor} from './cache-distributions/cache-factory';
|
||||
import {isCacheFeatureAvailable, IS_LINUX, IS_WINDOWS} from './utils';
|
||||
import {
|
||||
isCacheFeatureAvailable,
|
||||
logWarning,
|
||||
IS_LINUX,
|
||||
IS_WINDOWS
|
||||
} from './utils';
|
||||
|
||||
function isPyPyVersion(versionSpec: string) {
|
||||
return versionSpec.startsWith('pypy');
|
||||
@ -115,9 +120,4 @@ async function run() {
|
||||
}
|
||||
}
|
||||
|
||||
export function logWarning(message: string): void {
|
||||
const warningPrefix = '[warning]';
|
||||
core.info(`${warningPrefix}${message}`);
|
||||
}
|
||||
|
||||
run();
|
||||
|
@ -136,3 +136,8 @@ export async function getLinuxOSReleaseInfo() {
|
||||
|
||||
return `${osVersion}-${osRelease}`;
|
||||
}
|
||||
|
||||
export function logWarning(message: string): void {
|
||||
const warningPrefix = '[warning]';
|
||||
core.info(`${warningPrefix}${message}`);
|
||||
}
|
||||
|
Reference in New Issue
Block a user