setup-pdm/src/utils.ts
Frost Ming 21f59457b4
feat: Update action to deliminate the deprecation warnings (#20)
* feat: Update to deliminate deprecation warnings

* update dependencies

* change to the new API

* update env

* update dist js
2022-10-17 16:28:14 +08:00

37 lines
1.0 KiB
TypeScript

import * as core from '@actions/core';
import { useCpythonVersion } from 'setup-python/src/find-python';
import { findPyPyVersion } from 'setup-python/src/find-pypy';
function isPyPyVersion(versionSpec: string) {
return versionSpec.startsWith('pypy');
}
export async function findPythonVersion(version: string, architecture: string): Promise<string> {
let pythonVersion = '';
if (isPyPyVersion(version)) {
const installed = await findPyPyVersion(
version,
architecture,
true,
false
);
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`;
core.info(
`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
);
return installed.resolvedPythonVersion;
} else {
const installed = await useCpythonVersion(
version,
architecture,
true,
false
);
pythonVersion = installed.version;
core.info(`Successfully set up ${installed.impl} (${pythonVersion})`);
return installed.version;
}
}