mirror of
https://github.com/actions/setup-python.git
synced 2025-04-24 07:22:14 +00:00
Add OS info to the error message
This commit is contained in:
parent
1aafadcfb9
commit
6c87c81bbd
3 changed files with 104 additions and 4 deletions
48
dist/setup/index.js
vendored
48
dist/setup/index.js
vendored
|
@ -66377,8 +66377,9 @@ function useCpythonVersion(version, architecture, updateEnvironment, checkLatest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!installDir) {
|
if (!installDir) {
|
||||||
|
const osInfo = yield utils_1.getOSInfo();
|
||||||
throw new Error([
|
throw new Error([
|
||||||
`Version ${version} with arch ${architecture} not found`,
|
`Version ${version} with arch ${architecture} not found for ${osInfo}`,
|
||||||
`The list of all available versions can be found here: ${installer.MANIFEST_URL}`
|
`The list of all available versions can be found here: ${installer.MANIFEST_URL}`
|
||||||
].join(os.EOL));
|
].join(os.EOL));
|
||||||
}
|
}
|
||||||
|
@ -66951,7 +66952,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.logWarning = exports.getLinuxOSReleaseInfo = exports.isCacheFeatureAvailable = exports.isGhes = exports.validatePythonVersionFormatForPyPy = exports.writeExactPyPyVersionFile = exports.readExactPyPyVersionFile = exports.getPyPyVersionFromPath = exports.isNightlyKeyword = exports.validateVersion = exports.createSymlinkInFolder = exports.WINDOWS_PLATFORMS = exports.WINDOWS_ARCHS = exports.IS_MAC = exports.IS_LINUX = exports.IS_WINDOWS = void 0;
|
exports.getOSInfo = exports.logWarning = exports.getLinuxOSReleaseInfo = exports.isCacheFeatureAvailable = exports.isGhes = exports.validatePythonVersionFormatForPyPy = exports.writeExactPyPyVersionFile = exports.readExactPyPyVersionFile = exports.getPyPyVersionFromPath = exports.isNightlyKeyword = exports.validateVersion = exports.createSymlinkInFolder = exports.WINDOWS_PLATFORMS = exports.WINDOWS_ARCHS = exports.IS_MAC = exports.IS_LINUX = exports.IS_WINDOWS = void 0;
|
||||||
const cache = __importStar(__nccwpck_require__(7799));
|
const cache = __importStar(__nccwpck_require__(7799));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||||
|
@ -67058,6 +67059,49 @@ function logWarning(message) {
|
||||||
core.info(`${warningPrefix}${message}`);
|
core.info(`${warningPrefix}${message}`);
|
||||||
}
|
}
|
||||||
exports.logWarning = logWarning;
|
exports.logWarning = logWarning;
|
||||||
|
function getWindowsInfo() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const { stdout } = yield exec.getExecOutput('powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Caption"', undefined, {
|
||||||
|
silent: true
|
||||||
|
});
|
||||||
|
const windowsVersion = stdout.trim().split(' ')[3];
|
||||||
|
return `Windows ${windowsVersion}`;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function getMacOSInfo() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const { stdout } = yield exec.getExecOutput('sw_vers', ['-productVersion'], {
|
||||||
|
silent: true
|
||||||
|
});
|
||||||
|
const macOSVersion = stdout.trim();
|
||||||
|
return `macOS ${macOSVersion}`;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function getLinuxInfo() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const { stdout } = yield exec.getExecOutput('lsb_release', ['-i', '-r', '-s'], {
|
||||||
|
silent: true
|
||||||
|
});
|
||||||
|
const [osName, osVersion] = stdout.trim().split('\n');
|
||||||
|
return `${osName} ${osVersion}`;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function getOSInfo() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let osInfo;
|
||||||
|
if (exports.IS_WINDOWS) {
|
||||||
|
osInfo = yield getWindowsInfo();
|
||||||
|
}
|
||||||
|
else if (exports.IS_LINUX) {
|
||||||
|
osInfo = yield getLinuxInfo();
|
||||||
|
}
|
||||||
|
else if (exports.IS_MAC) {
|
||||||
|
osInfo = yield getMacOSInfo();
|
||||||
|
}
|
||||||
|
return osInfo;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.getOSInfo = getOSInfo;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import {IS_WINDOWS, IS_LINUX} from './utils';
|
import {IS_WINDOWS, IS_LINUX, getOSInfo} from './utils';
|
||||||
|
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
|
|
||||||
|
@ -85,9 +85,10 @@ export async function useCpythonVersion(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!installDir) {
|
if (!installDir) {
|
||||||
|
const osInfo = await getOSInfo();
|
||||||
throw new Error(
|
throw new Error(
|
||||||
[
|
[
|
||||||
`Version ${version} with arch ${architecture} not found`,
|
`Version ${version} with arch ${architecture} not found for ${osInfo}`,
|
||||||
`The list of all available versions can be found here: ${installer.MANIFEST_URL}`
|
`The list of all available versions can be found here: ${installer.MANIFEST_URL}`
|
||||||
].join(os.EOL)
|
].join(os.EOL)
|
||||||
);
|
);
|
||||||
|
|
55
src/utils.ts
55
src/utils.ts
|
@ -142,3 +142,58 @@ export function logWarning(message: string): void {
|
||||||
const warningPrefix = '[warning]';
|
const warningPrefix = '[warning]';
|
||||||
core.info(`${warningPrefix}${message}`);
|
core.info(`${warningPrefix}${message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getWindowsInfo() {
|
||||||
|
const {stdout} = await exec.getExecOutput(
|
||||||
|
'powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Caption"',
|
||||||
|
undefined,
|
||||||
|
{
|
||||||
|
silent: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const windowsVersion = stdout.trim().split(' ')[3];
|
||||||
|
|
||||||
|
return `Windows ${windowsVersion}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getMacOSInfo() {
|
||||||
|
const {stdout} = await exec.getExecOutput(
|
||||||
|
'sw_vers',
|
||||||
|
['-productVersion'],
|
||||||
|
{
|
||||||
|
silent: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const macOSVersion = stdout.trim();
|
||||||
|
|
||||||
|
return `macOS ${macOSVersion}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getLinuxInfo() {
|
||||||
|
const {stdout} = await exec.getExecOutput(
|
||||||
|
'lsb_release',
|
||||||
|
['-i', '-r', '-s'],
|
||||||
|
{
|
||||||
|
silent: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const [osName, osVersion] = stdout.trim().split('\n');
|
||||||
|
|
||||||
|
return `${osName} ${osVersion}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getOSInfo() {
|
||||||
|
let osInfo;
|
||||||
|
if (IS_WINDOWS){
|
||||||
|
osInfo = await getWindowsInfo();
|
||||||
|
} else if (IS_LINUX) {
|
||||||
|
osInfo = await getLinuxInfo();
|
||||||
|
} else if (IS_MAC) {
|
||||||
|
osInfo = await getMacOSInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
return osInfo;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue