mirror of
https://github.com/actions/setup-python.git
synced 2025-04-24 07:22:14 +00:00
Resolve comments
This commit is contained in:
parent
81b3a118a7
commit
16963e0b7e
5 changed files with 51 additions and 77 deletions
|
@ -8,11 +8,8 @@ inputs:
|
||||||
default: '3.x'
|
default: '3.x'
|
||||||
architecture:
|
architecture:
|
||||||
description: 'The target architecture (x86, x64) of the Python interpreter.'
|
description: 'The target architecture (x86, x64) of the Python interpreter.'
|
||||||
default: 'x64'
|
|
||||||
token:
|
token:
|
||||||
description: >
|
description: Used to pull python distributions from actions/python-versions. Since there's a default, this is typically not supplied by the user.
|
||||||
Personal access token (PAT) used to fetch the manifest file from master of repository
|
|
||||||
[Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
|
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
outputs:
|
outputs:
|
||||||
python-version:
|
python-version:
|
||||||
|
|
63
dist/index.js
vendored
63
dist/index.js
vendored
|
@ -2500,12 +2500,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(__webpack_require__(696));
|
const core = __importStar(__webpack_require__(696));
|
||||||
const finder = __importStar(__webpack_require__(507));
|
const finder = __importStar(__webpack_require__(507));
|
||||||
const path = __importStar(__webpack_require__(622));
|
const path = __importStar(__webpack_require__(622));
|
||||||
|
const os = __importStar(__webpack_require__(87));
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
let version = core.getInput('python-version');
|
let version = core.getInput('python-version');
|
||||||
if (version) {
|
if (version) {
|
||||||
const arch = core.getInput('architecture', { required: true });
|
const arch = core.getInput('architecture') || os.arch();
|
||||||
const installed = yield finder.findPythonVersion(version, arch);
|
const installed = yield finder.findPythonVersion(version, arch);
|
||||||
core.info(`Successfully setup ${installed.impl} (${installed.version})`);
|
core.info(`Successfully setup ${installed.impl} (${installed.version})`);
|
||||||
}
|
}
|
||||||
|
@ -2600,7 +2601,7 @@ const MANIFEST_REPO_OWNER = 'actions';
|
||||||
const MANIFEST_REPO_NAME = 'python-versions';
|
const MANIFEST_REPO_NAME = 'python-versions';
|
||||||
exports.MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/master/versions-manifest.json`;
|
exports.MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/master/versions-manifest.json`;
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
const IS_LINUX = process.platform === 'linux';
|
const IS_MACOS = process.platform === 'darwin';
|
||||||
function findReleaseFromManifest(semanticVersionSpec, architecture) {
|
function findReleaseFromManifest(semanticVersionSpec, architecture) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const manifest = yield tc.getManifestFromRepo(MANIFEST_REPO_OWNER, MANIFEST_REPO_NAME, AUTH_TOKEN);
|
const manifest = yield tc.getManifestFromRepo(MANIFEST_REPO_OWNER, MANIFEST_REPO_NAME, AUTH_TOKEN);
|
||||||
|
@ -2608,6 +2609,28 @@ function findReleaseFromManifest(semanticVersionSpec, architecture) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.findReleaseFromManifest = findReleaseFromManifest;
|
exports.findReleaseFromManifest = findReleaseFromManifest;
|
||||||
|
function _installPython(workingDirectory) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const options = {
|
||||||
|
cwd: workingDirectory,
|
||||||
|
silent: true,
|
||||||
|
listeners: {
|
||||||
|
stdout: (data) => {
|
||||||
|
core.debug(data.toString().trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (IS_WINDOWS) {
|
||||||
|
yield exec.exec('powershell', ['./setup.ps1'], options);
|
||||||
|
}
|
||||||
|
else if (IS_MACOS) {
|
||||||
|
yield exec.exec('bash', ['./setup.sh'], options);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
yield exec.exec('sudo', ['-n', 'bash', './setup.sh'], options);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
function installCpythonFromRelease(release) {
|
function installCpythonFromRelease(release) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const downloadUrl = release.files[0].download_url;
|
const downloadUrl = release.files[0].download_url;
|
||||||
|
@ -2622,25 +2645,8 @@ function installCpythonFromRelease(release) {
|
||||||
else {
|
else {
|
||||||
pythonExtractedFolder = yield tc.extractTar(pythonPath, `./${fileName}`);
|
pythonExtractedFolder = yield tc.extractTar(pythonPath, `./${fileName}`);
|
||||||
}
|
}
|
||||||
const options = {
|
|
||||||
cwd: pythonExtractedFolder,
|
|
||||||
silent: true,
|
|
||||||
listeners: {
|
|
||||||
stdout: (data) => {
|
|
||||||
core.debug(data.toString().trim());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
core.info('Execute installation script');
|
core.info('Execute installation script');
|
||||||
if (IS_WINDOWS) {
|
yield _installPython(pythonExtractedFolder);
|
||||||
yield exec.exec('powershell', ['./setup.ps1'], options);
|
|
||||||
}
|
|
||||||
else if (IS_LINUX) {
|
|
||||||
yield exec.exec('sudo', ['bash', './setup.sh'], options);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
yield exec.exec('bash', ['./setup.sh'], options);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.installCpythonFromRelease = installCpythonFromRelease;
|
exports.installCpythonFromRelease = installCpythonFromRelease;
|
||||||
|
@ -3648,23 +3654,6 @@ const os = __importStar(__webpack_require__(87));
|
||||||
const path = __importStar(__webpack_require__(622));
|
const path = __importStar(__webpack_require__(622));
|
||||||
const semver = __importStar(__webpack_require__(305));
|
const semver = __importStar(__webpack_require__(305));
|
||||||
const installer = __importStar(__webpack_require__(400));
|
const installer = __importStar(__webpack_require__(400));
|
||||||
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');
|
|
||||||
}
|
|
||||||
const core = __importStar(__webpack_require__(696));
|
const core = __importStar(__webpack_require__(696));
|
||||||
const tc = __importStar(__webpack_require__(475));
|
const tc = __importStar(__webpack_require__(475));
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
|
|
|
@ -5,23 +5,6 @@ import * as semver from 'semver';
|
||||||
|
|
||||||
import * as installer from './install-python';
|
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 core from '@actions/core';
|
||||||
import * as tc from '@actions/tool-cache';
|
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`;
|
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_WINDOWS = process.platform === 'win32';
|
||||||
const IS_LINUX = process.platform === 'linux';
|
const IS_MACOS = process.platform === 'darwin';
|
||||||
|
|
||||||
export async function findReleaseFromManifest(
|
export async function findReleaseFromManifest(
|
||||||
semanticVersionSpec: string,
|
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) {
|
export async function installCpythonFromRelease(release: tc.IToolRelease) {
|
||||||
const downloadUrl = release.files[0].download_url;
|
const downloadUrl = release.files[0].download_url;
|
||||||
|
|
||||||
|
@ -43,22 +63,6 @@ export async function installCpythonFromRelease(release: tc.IToolRelease) {
|
||||||
pythonExtractedFolder = await tc.extractTar(pythonPath, `./${fileName}`);
|
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');
|
core.info('Execute installation script');
|
||||||
if (IS_WINDOWS) {
|
await _installPython(pythonExtractedFolder);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as finder from './find-python';
|
import * as finder from './find-python';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
import * as os from 'os';
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
let version = core.getInput('python-version');
|
let version = core.getInput('python-version');
|
||||||
if (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);
|
const installed = await finder.findPythonVersion(version, arch);
|
||||||
core.info(`Successfully setup ${installed.impl} (${installed.version})`);
|
core.info(`Successfully setup ${installed.impl} (${installed.version})`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue