fix poetry python version

This commit is contained in:
Dmitry Shibanov 2022-05-04 12:33:57 +02:00
parent ae11205ec6
commit 70f6f2a532
3 changed files with 37 additions and 1 deletions

View file

@ -1,7 +1,8 @@
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';
@ -28,6 +29,21 @@ 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}`
);
if (exitCode) {
throw new Error(stderr);
}
} else {
core.warning('python binaries were not found in PATH.');
}
return paths;
}