mirror of
https://github.com/actions/setup-python.git
synced 2025-07-05 00:53:46 +00:00
Multiple Python versions from version-file in one environment
This makes the change from #567 also available for users of .python-version.
This commit is contained in:
parent
7a4f344e33
commit
d59aa9efa4
3 changed files with 49 additions and 12 deletions
17
dist/setup/index.js
vendored
17
dist/setup/index.js
vendored
|
@ -67984,6 +67984,15 @@ function cacheDependencies(cache, pythonVersion) {
|
|||
yield cacheDistributor.restoreCache();
|
||||
});
|
||||
}
|
||||
function readVersionFile(versionFile) {
|
||||
const data = fs_1.default.readFileSync(versionFile, 'utf8');
|
||||
const versions = data
|
||||
.split('\n')
|
||||
.map(input => input.trim())
|
||||
.filter(x => x !== '');
|
||||
core.info(`Resolved ${versionFile} as ${versions.join(', ')}`);
|
||||
return versions;
|
||||
}
|
||||
function resolveVersionInput() {
|
||||
const versions = core.getMultilineInput('python-version');
|
||||
let versionFile = core.getInput('python-version-file');
|
||||
|
@ -67997,16 +68006,12 @@ function resolveVersionInput() {
|
|||
if (!fs_1.default.existsSync(versionFile)) {
|
||||
throw new Error(`The specified python version file at: ${versionFile} doesn't exist.`);
|
||||
}
|
||||
const version = fs_1.default.readFileSync(versionFile, 'utf8');
|
||||
core.info(`Resolved ${versionFile} as ${version}`);
|
||||
return [version];
|
||||
return readVersionFile(versionFile);
|
||||
}
|
||||
utils_1.logWarning("Neither 'python-version' nor 'python-version-file' inputs were supplied. Attempting to find '.python-version' file.");
|
||||
versionFile = '.python-version';
|
||||
if (fs_1.default.existsSync(versionFile)) {
|
||||
const version = fs_1.default.readFileSync(versionFile, 'utf8');
|
||||
core.info(`Resolved ${versionFile} as ${version}`);
|
||||
return [version];
|
||||
return readVersionFile(versionFile);
|
||||
}
|
||||
utils_1.logWarning(`${versionFile} doesn't exist.`);
|
||||
return versions;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue