mirror of
				https://gitea.com/actions/setup-python.git
				synced 2025-11-04 07:47:09 +00:00 
			
		
		
		
	Install multiple python versions (#567)
This commit is contained in:
		
							
								
								
									
										46
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										46
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							@@ -66867,31 +66867,31 @@ function cacheDependencies(cache, pythonVersion) {
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
function resolveVersionInput() {
 | 
			
		||||
    let version = core.getInput('python-version');
 | 
			
		||||
    let versions = core.getMultilineInput('python-version');
 | 
			
		||||
    let versionFile = core.getInput('python-version-file');
 | 
			
		||||
    if (version && versionFile) {
 | 
			
		||||
    if (versions.length && versionFile) {
 | 
			
		||||
        core.warning('Both python-version and python-version-file inputs are specified, only python-version will be used.');
 | 
			
		||||
    }
 | 
			
		||||
    if (version) {
 | 
			
		||||
        return version;
 | 
			
		||||
    if (versions.length) {
 | 
			
		||||
        return versions;
 | 
			
		||||
    }
 | 
			
		||||
    if (versionFile) {
 | 
			
		||||
        if (!fs_1.default.existsSync(versionFile)) {
 | 
			
		||||
            throw new Error(`The specified python version file at: ${versionFile} doesn't exist.`);
 | 
			
		||||
        }
 | 
			
		||||
        version = fs_1.default.readFileSync(versionFile, 'utf8');
 | 
			
		||||
        const version = fs_1.default.readFileSync(versionFile, 'utf8');
 | 
			
		||||
        core.info(`Resolved ${versionFile} as ${version}`);
 | 
			
		||||
        return version;
 | 
			
		||||
        return [version];
 | 
			
		||||
    }
 | 
			
		||||
    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)) {
 | 
			
		||||
        version = fs_1.default.readFileSync(versionFile, 'utf8');
 | 
			
		||||
        const version = fs_1.default.readFileSync(versionFile, 'utf8');
 | 
			
		||||
        core.info(`Resolved ${versionFile} as ${version}`);
 | 
			
		||||
        return version;
 | 
			
		||||
        return [version];
 | 
			
		||||
    }
 | 
			
		||||
    utils_1.logWarning(`${versionFile} doesn't exist.`);
 | 
			
		||||
    return version;
 | 
			
		||||
    return versions;
 | 
			
		||||
}
 | 
			
		||||
function run() {
 | 
			
		||||
    var _a;
 | 
			
		||||
@@ -66904,22 +66904,26 @@ function run() {
 | 
			
		||||
        }
 | 
			
		||||
        core.debug(`Python is expected to be installed into ${process.env['RUNNER_TOOL_CACHE']}`);
 | 
			
		||||
        try {
 | 
			
		||||
            const version = resolveVersionInput();
 | 
			
		||||
            const versions = resolveVersionInput();
 | 
			
		||||
            const checkLatest = core.getBooleanInput('check-latest');
 | 
			
		||||
            if (version) {
 | 
			
		||||
                let pythonVersion;
 | 
			
		||||
            if (versions.length) {
 | 
			
		||||
                let pythonVersion = '';
 | 
			
		||||
                const arch = core.getInput('architecture') || os.arch();
 | 
			
		||||
                const updateEnvironment = core.getBooleanInput('update-environment');
 | 
			
		||||
                if (isPyPyVersion(version)) {
 | 
			
		||||
                    const installed = yield finderPyPy.findPyPyVersion(version, arch, updateEnvironment, checkLatest);
 | 
			
		||||
                    pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`;
 | 
			
		||||
                    core.info(`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`);
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    const installed = yield finder.useCpythonVersion(version, arch, updateEnvironment, checkLatest);
 | 
			
		||||
                    pythonVersion = installed.version;
 | 
			
		||||
                    core.info(`Successfully set up ${installed.impl} (${pythonVersion})`);
 | 
			
		||||
                core.startGroup('Installed versions');
 | 
			
		||||
                for (const version of versions) {
 | 
			
		||||
                    if (isPyPyVersion(version)) {
 | 
			
		||||
                        const installed = yield finderPyPy.findPyPyVersion(version, arch, updateEnvironment, checkLatest);
 | 
			
		||||
                        pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`;
 | 
			
		||||
                        core.info(`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`);
 | 
			
		||||
                    }
 | 
			
		||||
                    else {
 | 
			
		||||
                        const installed = yield finder.useCpythonVersion(version, arch, updateEnvironment, checkLatest);
 | 
			
		||||
                        pythonVersion = installed.version;
 | 
			
		||||
                        core.info(`Successfully set up ${installed.impl} (${pythonVersion})`);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                core.endGroup();
 | 
			
		||||
                const cache = core.getInput('cache');
 | 
			
		||||
                if (cache && utils_1.isCacheFeatureAvailable()) {
 | 
			
		||||
                    yield cacheDependencies(cache, pythonVersion);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user