mirror of
https://github.com/actions/setup-python.git
synced 2026-01-21 13:48:54 +08:00
Revert "Update releases/v1 with changes from master (#67)"
This reverts commit bdd6409dc1.
This commit is contained in:
parent
bdd6409dc1
commit
39f340c482
187 changed files with 15033 additions and 6120 deletions
|
|
@ -51,13 +51,13 @@ function binDir(installDir: string): string {
|
|||
// A particular version of PyPy may contain one or more versions of the Python interpreter.
|
||||
// For example, PyPy 7.0 contains Python 2.7, 3.5, and 3.6-alpha.
|
||||
// We only care about the Python version, so we don't use the PyPy version for the tool cache.
|
||||
function usePyPy(majorVersion: 2 | 3, architecture: string): InstalledVersion {
|
||||
function usePyPy(majorVersion: 2 | 3, architecture: string): void {
|
||||
const findPyPy = tc.find.bind(undefined, 'PyPy', majorVersion.toString());
|
||||
let installDir: string | null = findPyPy(architecture);
|
||||
|
||||
if (!installDir && IS_WINDOWS) {
|
||||
// PyPy only precompiles binaries for x86, but the architecture parameter defaults to x64.
|
||||
// On our Windows virtual environments, we only install an x86 version.
|
||||
// On Hosted VS2017, we only install an x86 version.
|
||||
// Fall back to x86.
|
||||
installDir = findPyPy('x86');
|
||||
}
|
||||
|
|
@ -77,17 +77,12 @@ function usePyPy(majorVersion: 2 | 3, architecture: string): InstalledVersion {
|
|||
|
||||
core.addPath(installDir);
|
||||
core.addPath(_binDir);
|
||||
|
||||
const impl = 'pypy' + majorVersion.toString();
|
||||
core.setOutput('python-version', impl);
|
||||
|
||||
return {impl: impl, version: versionFromPath(installDir)};
|
||||
}
|
||||
|
||||
async function useCpythonVersion(
|
||||
version: string,
|
||||
architecture: string
|
||||
): Promise<InstalledVersion> {
|
||||
): Promise<void> {
|
||||
const desugaredVersionSpec = desugarDevVersion(version);
|
||||
const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
|
||||
core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`);
|
||||
|
|
@ -125,7 +120,7 @@ async function useCpythonVersion(
|
|||
|
||||
if (IS_WINDOWS) {
|
||||
// Add --user directory
|
||||
// `installDir` from tool cache should look like $RUNNER_TOOL_CACHE/Python/<semantic version>/x64/
|
||||
// `installDir` from tool cache should look like $AGENT_TOOLSDIRECTORY/Python/<semantic version>/x64/
|
||||
// So if `findLocalTool` succeeded above, we must have a conformant `installDir`
|
||||
const version = path.basename(path.dirname(installDir));
|
||||
const major = semver.major(version);
|
||||
|
|
@ -140,11 +135,6 @@ async function useCpythonVersion(
|
|||
core.addPath(userScriptsDir);
|
||||
}
|
||||
// On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
|
||||
|
||||
const installed = versionFromPath(installDir);
|
||||
core.setOutput('python-version', installed);
|
||||
|
||||
return {impl: 'CPython', version: installed};
|
||||
}
|
||||
|
||||
/** Convert versions like `3.8-dev` to a version like `>= 3.8.0-a0`. */
|
||||
|
|
@ -157,19 +147,6 @@ function desugarDevVersion(versionSpec: string) {
|
|||
}
|
||||
}
|
||||
|
||||
/** Extracts python version from install path from hosted tool cache as described in README.md */
|
||||
function versionFromPath(installDir: string) {
|
||||
const parts = installDir.split(path.sep);
|
||||
const idx = parts.findIndex(part => part === 'PyPy' || part === 'Python');
|
||||
|
||||
return parts[idx + 1] || '';
|
||||
}
|
||||
|
||||
interface InstalledVersion {
|
||||
impl: string;
|
||||
version: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Python's prelease versions look like `3.7.0b2`.
|
||||
* This is the one part of Python versioning that does not look like semantic versioning, which specifies `3.7.0-b2`.
|
||||
|
|
@ -183,7 +160,7 @@ export function pythonVersionToSemantic(versionSpec: string) {
|
|||
export async function findPythonVersion(
|
||||
version: string,
|
||||
architecture: string
|
||||
): Promise<InstalledVersion> {
|
||||
): Promise<void> {
|
||||
switch (version.toUpperCase()) {
|
||||
case 'PYPY2':
|
||||
return usePyPy(2, architecture);
|
||||
|
|
|
|||
|
|
@ -7,11 +7,10 @@ async function run() {
|
|||
let version = core.getInput('python-version');
|
||||
if (version) {
|
||||
const arch: string = core.getInput('architecture', {required: true});
|
||||
const installed = await finder.findPythonVersion(version, arch);
|
||||
core.info(`Successfully setup ${installed.impl} (${installed.version})`);
|
||||
await finder.findPythonVersion(version, arch);
|
||||
}
|
||||
const matchersPath = path.join(__dirname, '..', '.github');
|
||||
core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);
|
||||
console.log(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);
|
||||
} catch (err) {
|
||||
core.setFailed(err.message);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue