mirror of
https://github.com/actions/setup-python.git
synced 2025-07-02 07:33:47 +00:00
Resolve comments
This commit is contained in:
parent
81b3a118a7
commit
16963e0b7e
5 changed files with 51 additions and 77 deletions
|
@ -5,23 +5,6 @@ import * as semver from 'semver';
|
|||
|
||||
import * as installer from './install-python';
|
||||
|
||||
let cacheDirectory = process.env['RUNNER_TOOLSDIRECTORY'] || '';
|
||||
|
||||
if (!cacheDirectory) {
|
||||
let baseLocation;
|
||||
if (process.platform === 'win32') {
|
||||
// On windows use the USERPROFILE env variable
|
||||
baseLocation = process.env['USERPROFILE'] || 'C:\\';
|
||||
} else {
|
||||
if (process.platform === 'darwin') {
|
||||
baseLocation = '/Users';
|
||||
} else {
|
||||
baseLocation = '/home';
|
||||
}
|
||||
}
|
||||
cacheDirectory = path.join(baseLocation, 'actions', 'cache');
|
||||
}
|
||||
|
||||
import * as core from '@actions/core';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ const MANIFEST_REPO_NAME = 'python-versions';
|
|||
export const MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/master/versions-manifest.json`;
|
||||
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
const IS_LINUX = process.platform === 'linux';
|
||||
const IS_MACOS = process.platform === 'darwin';
|
||||
|
||||
export async function findReleaseFromManifest(
|
||||
semanticVersionSpec: string,
|
||||
|
@ -29,6 +29,26 @@ export async function findReleaseFromManifest(
|
|||
);
|
||||
}
|
||||
|
||||
async function _installPython(workingDirectory: string) {
|
||||
const options: ExecOptions = {
|
||||
cwd: workingDirectory,
|
||||
silent: true,
|
||||
listeners: {
|
||||
stdout: (data: Buffer) => {
|
||||
core.debug(data.toString().trim());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (IS_WINDOWS) {
|
||||
await exec.exec('powershell', ['./setup.ps1'], options);
|
||||
} else if (IS_MACOS) {
|
||||
await exec.exec('bash', ['./setup.sh'], options);
|
||||
} else {
|
||||
await exec.exec('sudo', ['-n', 'bash', './setup.sh'], options);
|
||||
}
|
||||
}
|
||||
|
||||
export async function installCpythonFromRelease(release: tc.IToolRelease) {
|
||||
const downloadUrl = release.files[0].download_url;
|
||||
|
||||
|
@ -43,22 +63,6 @@ export async function installCpythonFromRelease(release: tc.IToolRelease) {
|
|||
pythonExtractedFolder = await tc.extractTar(pythonPath, `./${fileName}`);
|
||||
}
|
||||
|
||||
const options: ExecOptions = {
|
||||
cwd: pythonExtractedFolder,
|
||||
silent: true,
|
||||
listeners: {
|
||||
stdout: (data: Buffer) => {
|
||||
core.debug(data.toString().trim());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
core.info('Execute installation script');
|
||||
if (IS_WINDOWS) {
|
||||
await exec.exec('powershell', ['./setup.ps1'], options);
|
||||
} else if (IS_LINUX) {
|
||||
await exec.exec('sudo', ['bash', './setup.sh'], options);
|
||||
} else {
|
||||
await exec.exec('bash', ['./setup.sh'], options);
|
||||
}
|
||||
await _installPython(pythonExtractedFolder);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import * as core from '@actions/core';
|
||||
import * as finder from './find-python';
|
||||
import * as path from 'path';
|
||||
import * as os from 'os';
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
let version = core.getInput('python-version');
|
||||
if (version) {
|
||||
const arch: string = core.getInput('architecture', {required: true});
|
||||
const arch: string = core.getInput('architecture') || os.arch();
|
||||
const installed = await finder.findPythonVersion(version, arch);
|
||||
core.info(`Successfully setup ${installed.impl} (${installed.version})`);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue