mirror of
https://github.com/actions/setup-python.git
synced 2025-04-24 07:22:14 +00:00
Add Env Files
This commit is contained in:
parent
985150d1f6
commit
2bbe3d89d7
2 changed files with 318 additions and 226 deletions
538
dist/index.js
vendored
538
dist/index.js
vendored
|
@ -1243,6 +1243,32 @@ class SemVer {
|
||||||
module.exports = SemVer
|
module.exports = SemVer
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 82:
|
||||||
|
/***/ (function(__unusedmodule, exports) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
// We use any as a valid input type
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
/**
|
||||||
|
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
||||||
|
* @param input input to sanitize into a string
|
||||||
|
*/
|
||||||
|
function toCommandValue(input) {
|
||||||
|
if (input === null || input === undefined) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
else if (typeof input === 'string' || input instanceof String) {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
return JSON.stringify(input);
|
||||||
|
}
|
||||||
|
exports.toCommandValue = toCommandValue;
|
||||||
|
//# sourceMappingURL=utils.js.map
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 87:
|
/***/ 87:
|
||||||
|
@ -1252,6 +1278,42 @@ module.exports = require("os");
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 102:
|
||||||
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
// For internal use, subject to change.
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
|
result["default"] = mod;
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
// We use any as a valid input type
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
const fs = __importStar(__webpack_require__(747));
|
||||||
|
const os = __importStar(__webpack_require__(87));
|
||||||
|
const utils_1 = __webpack_require__(82);
|
||||||
|
function issueCommand(command, message) {
|
||||||
|
const filePath = process.env[`GITHUB_${command}`];
|
||||||
|
if (!filePath) {
|
||||||
|
throw new Error(`Unable to find environment variable for file command ${command}`);
|
||||||
|
}
|
||||||
|
if (!fs.existsSync(filePath)) {
|
||||||
|
throw new Error(`Missing file at path: ${filePath}`);
|
||||||
|
}
|
||||||
|
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
|
||||||
|
encoding: 'utf8'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.issueCommand = issueCommand;
|
||||||
|
//# sourceMappingURL=file-command.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
/***/ 120:
|
/***/ 120:
|
||||||
/***/ (function(module, __unusedexports, __webpack_require__) {
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
||||||
|
|
||||||
|
@ -2235,45 +2297,45 @@ const Range = __webpack_require__(124)
|
||||||
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(__webpack_require__(470));
|
const core = __importStar(__webpack_require__(470));
|
||||||
const finder = __importStar(__webpack_require__(927));
|
const finder = __importStar(__webpack_require__(927));
|
||||||
const path = __importStar(__webpack_require__(622));
|
const path = __importStar(__webpack_require__(622));
|
||||||
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', { required: true });
|
||||||
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})`);
|
||||||
}
|
}
|
||||||
const matchersPath = path.join(__dirname, '..', '.github');
|
const matchersPath = path.join(__dirname, '..', '.github');
|
||||||
core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);
|
core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
core.setFailed(err.message);
|
core.setFailed(err.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
run();
|
run();
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
@ -2422,6 +2484,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const os = __importStar(__webpack_require__(87));
|
const os = __importStar(__webpack_require__(87));
|
||||||
|
const utils_1 = __webpack_require__(82);
|
||||||
/**
|
/**
|
||||||
* Commands
|
* Commands
|
||||||
*
|
*
|
||||||
|
@ -2476,13 +2539,13 @@ class Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function escapeData(s) {
|
function escapeData(s) {
|
||||||
return (s || '')
|
return utils_1.toCommandValue(s)
|
||||||
.replace(/%/g, '%25')
|
.replace(/%/g, '%25')
|
||||||
.replace(/\r/g, '%0D')
|
.replace(/\r/g, '%0D')
|
||||||
.replace(/\n/g, '%0A');
|
.replace(/\n/g, '%0A');
|
||||||
}
|
}
|
||||||
function escapeProperty(s) {
|
function escapeProperty(s) {
|
||||||
return (s || '')
|
return utils_1.toCommandValue(s)
|
||||||
.replace(/%/g, '%25')
|
.replace(/%/g, '%25')
|
||||||
.replace(/\r/g, '%0D')
|
.replace(/\r/g, '%0D')
|
||||||
.replace(/\n/g, '%0A')
|
.replace(/\n/g, '%0A')
|
||||||
|
@ -2603,6 +2666,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const command_1 = __webpack_require__(431);
|
const command_1 = __webpack_require__(431);
|
||||||
|
const file_command_1 = __webpack_require__(102);
|
||||||
|
const utils_1 = __webpack_require__(82);
|
||||||
const os = __importStar(__webpack_require__(87));
|
const os = __importStar(__webpack_require__(87));
|
||||||
const path = __importStar(__webpack_require__(622));
|
const path = __importStar(__webpack_require__(622));
|
||||||
/**
|
/**
|
||||||
|
@ -2625,11 +2690,21 @@ var ExitCode;
|
||||||
/**
|
/**
|
||||||
* Sets env variable for this action and future actions in the job
|
* Sets env variable for this action and future actions in the job
|
||||||
* @param name the name of the variable to set
|
* @param name the name of the variable to set
|
||||||
* @param val the value of the variable
|
* @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
|
||||||
*/
|
*/
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function exportVariable(name, val) {
|
function exportVariable(name, val) {
|
||||||
process.env[name] = val;
|
const convertedVal = utils_1.toCommandValue(val);
|
||||||
command_1.issueCommand('set-env', { name }, val);
|
process.env[name] = convertedVal;
|
||||||
|
const filePath = process.env['GITHUB_ENV'] || '';
|
||||||
|
if (filePath) {
|
||||||
|
const delimiter = '_GitHubActionsFileCommandDelimeter_';
|
||||||
|
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
|
||||||
|
file_command_1.issueCommand('ENV', commandValue);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
command_1.issueCommand('set-env', { name }, convertedVal);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exports.exportVariable = exportVariable;
|
exports.exportVariable = exportVariable;
|
||||||
/**
|
/**
|
||||||
|
@ -2645,7 +2720,13 @@ exports.setSecret = setSecret;
|
||||||
* @param inputPath
|
* @param inputPath
|
||||||
*/
|
*/
|
||||||
function addPath(inputPath) {
|
function addPath(inputPath) {
|
||||||
command_1.issueCommand('add-path', {}, inputPath);
|
const filePath = process.env['GITHUB_PATH'] || '';
|
||||||
|
if (filePath) {
|
||||||
|
file_command_1.issueCommand('PATH', inputPath);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
command_1.issueCommand('add-path', {}, inputPath);
|
||||||
|
}
|
||||||
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
||||||
}
|
}
|
||||||
exports.addPath = addPath;
|
exports.addPath = addPath;
|
||||||
|
@ -2668,12 +2749,22 @@ exports.getInput = getInput;
|
||||||
* Sets the value of an output.
|
* Sets the value of an output.
|
||||||
*
|
*
|
||||||
* @param name name of the output to set
|
* @param name name of the output to set
|
||||||
* @param value value to store
|
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
|
||||||
*/
|
*/
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function setOutput(name, value) {
|
function setOutput(name, value) {
|
||||||
command_1.issueCommand('set-output', { name }, value);
|
command_1.issueCommand('set-output', { name }, value);
|
||||||
}
|
}
|
||||||
exports.setOutput = setOutput;
|
exports.setOutput = setOutput;
|
||||||
|
/**
|
||||||
|
* Enables or disables the echoing of commands into stdout for the rest of the step.
|
||||||
|
* Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function setCommandEcho(enabled) {
|
||||||
|
command_1.issue('echo', enabled ? 'on' : 'off');
|
||||||
|
}
|
||||||
|
exports.setCommandEcho = setCommandEcho;
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
// Results
|
// Results
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
@ -2707,18 +2798,18 @@ function debug(message) {
|
||||||
exports.debug = debug;
|
exports.debug = debug;
|
||||||
/**
|
/**
|
||||||
* Adds an error issue
|
* Adds an error issue
|
||||||
* @param message error issue message
|
* @param message error issue message. Errors will be converted to string via toString()
|
||||||
*/
|
*/
|
||||||
function error(message) {
|
function error(message) {
|
||||||
command_1.issue('error', message);
|
command_1.issue('error', message instanceof Error ? message.toString() : message);
|
||||||
}
|
}
|
||||||
exports.error = error;
|
exports.error = error;
|
||||||
/**
|
/**
|
||||||
* Adds an warning issue
|
* Adds an warning issue
|
||||||
* @param message warning issue message
|
* @param message warning issue message. Errors will be converted to string via toString()
|
||||||
*/
|
*/
|
||||||
function warning(message) {
|
function warning(message) {
|
||||||
command_1.issue('warning', message);
|
command_1.issue('warning', message instanceof Error ? message.toString() : message);
|
||||||
}
|
}
|
||||||
exports.warning = warning;
|
exports.warning = warning;
|
||||||
/**
|
/**
|
||||||
|
@ -2776,8 +2867,9 @@ exports.group = group;
|
||||||
* Saves state for current action, the state can only be retrieved by this action's post job execution.
|
* Saves state for current action, the state can only be retrieved by this action's post job execution.
|
||||||
*
|
*
|
||||||
* @param name name of the state to store
|
* @param name name of the state to store
|
||||||
* @param value value to store
|
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
|
||||||
*/
|
*/
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function saveState(name, value) {
|
function saveState(name, value) {
|
||||||
command_1.issueCommand('save-state', { name }, value);
|
command_1.issueCommand('save-state', { name }, value);
|
||||||
}
|
}
|
||||||
|
@ -6258,178 +6350,178 @@ module.exports = lte
|
||||||
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const os = __importStar(__webpack_require__(87));
|
const os = __importStar(__webpack_require__(87));
|
||||||
const path = __importStar(__webpack_require__(622));
|
const path = __importStar(__webpack_require__(622));
|
||||||
const semver = __importStar(__webpack_require__(876));
|
const semver = __importStar(__webpack_require__(876));
|
||||||
let cacheDirectory = process.env['RUNNER_TOOLSDIRECTORY'] || '';
|
let cacheDirectory = process.env['RUNNER_TOOLSDIRECTORY'] || '';
|
||||||
if (!cacheDirectory) {
|
if (!cacheDirectory) {
|
||||||
let baseLocation;
|
let baseLocation;
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
// On windows use the USERPROFILE env variable
|
// On windows use the USERPROFILE env variable
|
||||||
baseLocation = process.env['USERPROFILE'] || 'C:\\';
|
baseLocation = process.env['USERPROFILE'] || 'C:\\';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
baseLocation = '/Users';
|
baseLocation = '/Users';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
baseLocation = '/home';
|
baseLocation = '/home';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cacheDirectory = path.join(baseLocation, 'actions', 'cache');
|
cacheDirectory = path.join(baseLocation, 'actions', 'cache');
|
||||||
}
|
}
|
||||||
const core = __importStar(__webpack_require__(470));
|
const core = __importStar(__webpack_require__(470));
|
||||||
const tc = __importStar(__webpack_require__(533));
|
const tc = __importStar(__webpack_require__(533));
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
// Python has "scripts" or "bin" directories where command-line tools that come with packages are installed.
|
// Python has "scripts" or "bin" directories where command-line tools that come with packages are installed.
|
||||||
// This is where pip is, along with anything that pip installs.
|
// This is where pip is, along with anything that pip installs.
|
||||||
// There is a seperate directory for `pip install --user`.
|
// There is a seperate directory for `pip install --user`.
|
||||||
//
|
//
|
||||||
// For reference, these directories are as follows:
|
// For reference, these directories are as follows:
|
||||||
// macOS / Linux:
|
// macOS / Linux:
|
||||||
// <sys.prefix>/bin (by default /usr/local/bin, but not on hosted agents -- see the `else`)
|
// <sys.prefix>/bin (by default /usr/local/bin, but not on hosted agents -- see the `else`)
|
||||||
// (--user) ~/.local/bin
|
// (--user) ~/.local/bin
|
||||||
// Windows:
|
// Windows:
|
||||||
// <Python installation dir>\Scripts
|
// <Python installation dir>\Scripts
|
||||||
// (--user) %APPDATA%\Python\PythonXY\Scripts
|
// (--user) %APPDATA%\Python\PythonXY\Scripts
|
||||||
// See https://docs.python.org/3/library/sysconfig.html
|
// See https://docs.python.org/3/library/sysconfig.html
|
||||||
function binDir(installDir) {
|
function binDir(installDir) {
|
||||||
if (IS_WINDOWS) {
|
if (IS_WINDOWS) {
|
||||||
return path.join(installDir, 'Scripts');
|
return path.join(installDir, 'Scripts');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return path.join(installDir, 'bin');
|
return path.join(installDir, 'bin');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Note on the tool cache layout for PyPy:
|
// Note on the tool cache layout for PyPy:
|
||||||
// PyPy has its own versioning scheme that doesn't follow the Python versioning scheme.
|
// PyPy has its own versioning scheme that doesn't follow the Python versioning scheme.
|
||||||
// A particular version of PyPy may contain one or more versions of the Python interpreter.
|
// 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.
|
// 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.
|
// We only care about the Python version, so we don't use the PyPy version for the tool cache.
|
||||||
function usePyPy(majorVersion, architecture) {
|
function usePyPy(majorVersion, architecture) {
|
||||||
const findPyPy = tc.find.bind(undefined, 'PyPy', majorVersion.toString());
|
const findPyPy = tc.find.bind(undefined, 'PyPy', majorVersion.toString());
|
||||||
let installDir = findPyPy(architecture);
|
let installDir = findPyPy(architecture);
|
||||||
if (!installDir && IS_WINDOWS) {
|
if (!installDir && IS_WINDOWS) {
|
||||||
// PyPy only precompiles binaries for x86, but the architecture parameter defaults to x64.
|
// 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 our Windows virtual environments, we only install an x86 version.
|
||||||
// Fall back to x86.
|
// Fall back to x86.
|
||||||
installDir = findPyPy('x86');
|
installDir = findPyPy('x86');
|
||||||
}
|
}
|
||||||
if (!installDir) {
|
if (!installDir) {
|
||||||
// PyPy not installed in $(Agent.ToolsDirectory)
|
// PyPy not installed in $(Agent.ToolsDirectory)
|
||||||
throw new Error(`PyPy ${majorVersion} not found`);
|
throw new Error(`PyPy ${majorVersion} not found`);
|
||||||
}
|
}
|
||||||
// For PyPy, Windows uses 'bin', not 'Scripts'.
|
// For PyPy, Windows uses 'bin', not 'Scripts'.
|
||||||
const _binDir = path.join(installDir, 'bin');
|
const _binDir = path.join(installDir, 'bin');
|
||||||
// On Linux and macOS, the Python interpreter is in 'bin'.
|
// On Linux and macOS, the Python interpreter is in 'bin'.
|
||||||
// On Windows, it is in the installation root.
|
// On Windows, it is in the installation root.
|
||||||
const pythonLocation = IS_WINDOWS ? installDir : _binDir;
|
const pythonLocation = IS_WINDOWS ? installDir : _binDir;
|
||||||
core.exportVariable('pythonLocation', pythonLocation);
|
core.exportVariable('pythonLocation', pythonLocation);
|
||||||
core.addPath(installDir);
|
core.addPath(installDir);
|
||||||
core.addPath(_binDir);
|
core.addPath(_binDir);
|
||||||
const impl = 'pypy' + majorVersion.toString();
|
const impl = 'pypy' + majorVersion.toString();
|
||||||
core.setOutput('python-version', impl);
|
core.setOutput('python-version', impl);
|
||||||
return { impl: impl, version: versionFromPath(installDir) };
|
return { impl: impl, version: versionFromPath(installDir) };
|
||||||
}
|
}
|
||||||
function useCpythonVersion(version, architecture) {
|
function useCpythonVersion(version, architecture) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const desugaredVersionSpec = desugarDevVersion(version);
|
const desugaredVersionSpec = desugarDevVersion(version);
|
||||||
const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
|
const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
|
||||||
core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`);
|
core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`);
|
||||||
const installDir = tc.find('Python', semanticVersionSpec, architecture);
|
const installDir = tc.find('Python', semanticVersionSpec, architecture);
|
||||||
if (!installDir) {
|
if (!installDir) {
|
||||||
// Fail and list available versions
|
// Fail and list available versions
|
||||||
const x86Versions = tc
|
const x86Versions = tc
|
||||||
.findAllVersions('Python', 'x86')
|
.findAllVersions('Python', 'x86')
|
||||||
.map(s => `${s} (x86)`)
|
.map(s => `${s} (x86)`)
|
||||||
.join(os.EOL);
|
.join(os.EOL);
|
||||||
const x64Versions = tc
|
const x64Versions = tc
|
||||||
.findAllVersions('Python', 'x64')
|
.findAllVersions('Python', 'x64')
|
||||||
.map(s => `${s} (x64)`)
|
.map(s => `${s} (x64)`)
|
||||||
.join(os.EOL);
|
.join(os.EOL);
|
||||||
throw new Error([
|
throw new Error([
|
||||||
`Version ${version} with arch ${architecture} not found`,
|
`Version ${version} with arch ${architecture} not found`,
|
||||||
'Available versions:',
|
'Available versions:',
|
||||||
x86Versions,
|
x86Versions,
|
||||||
x64Versions
|
x64Versions
|
||||||
].join(os.EOL));
|
].join(os.EOL));
|
||||||
}
|
}
|
||||||
core.exportVariable('pythonLocation', installDir);
|
core.exportVariable('pythonLocation', installDir);
|
||||||
core.addPath(installDir);
|
core.addPath(installDir);
|
||||||
core.addPath(binDir(installDir));
|
core.addPath(binDir(installDir));
|
||||||
if (IS_WINDOWS) {
|
if (IS_WINDOWS) {
|
||||||
// Add --user directory
|
// Add --user directory
|
||||||
// `installDir` from tool cache should look like $RUNNER_TOOL_CACHE/Python/<semantic version>/x64/
|
// `installDir` from tool cache should look like $RUNNER_TOOL_CACHE/Python/<semantic version>/x64/
|
||||||
// So if `findLocalTool` succeeded above, we must have a conformant `installDir`
|
// So if `findLocalTool` succeeded above, we must have a conformant `installDir`
|
||||||
const version = path.basename(path.dirname(installDir));
|
const version = path.basename(path.dirname(installDir));
|
||||||
const major = semver.major(version);
|
const major = semver.major(version);
|
||||||
const minor = semver.minor(version);
|
const minor = semver.minor(version);
|
||||||
const userScriptsDir = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}`, 'Scripts');
|
const userScriptsDir = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}`, 'Scripts');
|
||||||
core.addPath(userScriptsDir);
|
core.addPath(userScriptsDir);
|
||||||
}
|
}
|
||||||
// On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
|
// On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
|
||||||
const installed = versionFromPath(installDir);
|
const installed = versionFromPath(installDir);
|
||||||
core.setOutput('python-version', installed);
|
core.setOutput('python-version', installed);
|
||||||
return { impl: 'CPython', version: installed };
|
return { impl: 'CPython', version: installed };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/** Convert versions like `3.8-dev` to a version like `>= 3.8.0-a0`. */
|
/** Convert versions like `3.8-dev` to a version like `>= 3.8.0-a0`. */
|
||||||
function desugarDevVersion(versionSpec) {
|
function desugarDevVersion(versionSpec) {
|
||||||
if (versionSpec.endsWith('-dev')) {
|
if (versionSpec.endsWith('-dev')) {
|
||||||
const versionRoot = versionSpec.slice(0, -'-dev'.length);
|
const versionRoot = versionSpec.slice(0, -'-dev'.length);
|
||||||
return `>= ${versionRoot}.0-a0`;
|
return `>= ${versionRoot}.0-a0`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return versionSpec;
|
return versionSpec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** Extracts python version from install path from hosted tool cache as described in README.md */
|
/** Extracts python version from install path from hosted tool cache as described in README.md */
|
||||||
function versionFromPath(installDir) {
|
function versionFromPath(installDir) {
|
||||||
const parts = installDir.split(path.sep);
|
const parts = installDir.split(path.sep);
|
||||||
const idx = parts.findIndex(part => part === 'PyPy' || part === 'Python');
|
const idx = parts.findIndex(part => part === 'PyPy' || part === 'Python');
|
||||||
return parts[idx + 1] || '';
|
return parts[idx + 1] || '';
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Python's prelease versions look like `3.7.0b2`.
|
* 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`.
|
* This is the one part of Python versioning that does not look like semantic versioning, which specifies `3.7.0-b2`.
|
||||||
* If the version spec contains prerelease versions, we need to convert them to the semantic version equivalent.
|
* If the version spec contains prerelease versions, we need to convert them to the semantic version equivalent.
|
||||||
*/
|
*/
|
||||||
function pythonVersionToSemantic(versionSpec) {
|
function pythonVersionToSemantic(versionSpec) {
|
||||||
const prereleaseVersion = /(\d+\.\d+\.\d+)((?:a|b|rc)\d*)/g;
|
const prereleaseVersion = /(\d+\.\d+\.\d+)((?:a|b|rc)\d*)/g;
|
||||||
return versionSpec.replace(prereleaseVersion, '$1-$2');
|
return versionSpec.replace(prereleaseVersion, '$1-$2');
|
||||||
}
|
}
|
||||||
exports.pythonVersionToSemantic = pythonVersionToSemantic;
|
exports.pythonVersionToSemantic = pythonVersionToSemantic;
|
||||||
function findPythonVersion(version, architecture) {
|
function findPythonVersion(version, architecture) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
switch (version.toUpperCase()) {
|
switch (version.toUpperCase()) {
|
||||||
case 'PYPY2':
|
case 'PYPY2':
|
||||||
return usePyPy(2, architecture);
|
return usePyPy(2, architecture);
|
||||||
case 'PYPY3':
|
case 'PYPY3':
|
||||||
return usePyPy(3, architecture);
|
return usePyPy(3, architecture);
|
||||||
default:
|
default:
|
||||||
return yield useCpythonVersion(version, architecture);
|
return yield useCpythonVersion(version, architecture);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.findPythonVersion = findPythonVersion;
|
exports.findPythonVersion = findPythonVersion;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
6
package-lock.json
generated
6
package-lock.json
generated
|
@ -5,9 +5,9 @@
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": {
|
"@actions/core": {
|
||||||
"version": "1.2.3",
|
"version": "1.2.6",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
|
||||||
"integrity": "sha512-Wp4xnyokakM45Uuj4WLUxdsa8fJjKVl1fDTsPbTEcTcuu0Nb26IPQbOtjmnfaCPGcaoPOOqId8H9NapZ8gii4w=="
|
"integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA=="
|
||||||
},
|
},
|
||||||
"@actions/exec": {
|
"@actions/exec": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
|
|
Loading…
Add table
Reference in a new issue