mirror of
https://github.com/actions/setup-python.git
synced 2025-07-18 09:48:21 +02:00
Extract python version from explicit main group (poetry)
As documented here https://python-poetry.org/docs/managing-dependencies/#dependency-groups ```toml [tool.poetry.dependencies] ``` and ```toml [tool.poetry.group.main.dependencies] ``` Are equivalent
This commit is contained in:
parent
b64ffcaf5b
commit
2eb6c43547
2 changed files with 25 additions and 5 deletions
18
src/utils.ts
18
src/utils.ts
|
@ -228,15 +228,23 @@ export function getVersionInputFromTomlFile(versionFile: string): string[] {
|
|||
|
||||
if ('project' in pyprojectConfig) {
|
||||
// standard project metadata (PEP 621)
|
||||
keys = ['project', 'requires-python'];
|
||||
keys = [['project', 'requires-python']];
|
||||
} else {
|
||||
// python poetry
|
||||
keys = ['tool', 'poetry', 'dependencies', 'python'];
|
||||
keys = [
|
||||
// implicit group main
|
||||
['tool', 'poetry', 'dependencies', 'python'],
|
||||
// explicit group main
|
||||
['tool', 'poetry', 'group', 'main', 'dependencies', 'python']
|
||||
];
|
||||
}
|
||||
const versions = [];
|
||||
const version = extractValue(pyprojectConfig, keys);
|
||||
if (version !== undefined) {
|
||||
versions.push(version);
|
||||
for (const key of keys) {
|
||||
const version = extractValue(pyprojectConfig, key);
|
||||
if (version !== undefined) {
|
||||
versions.push(version);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
core.info(`Extracted ${versions} from ${versionFile}`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue