mirror of
https://code.forgejo.org/actions/setup-python
synced 2025-06-15 15:34:14 +02:00
Fix poetry version (#445)
This commit is contained in:
parent
592a7a7a45
commit
49a521fa06
7 changed files with 80 additions and 19 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue