You've already forked setup-python
mirror of
https://github.com/actions/setup-python.git
synced 2025-09-27 15:11:26 +07:00
Add support for pip-install input (#1201)
* Add pip-install input * Improve error message * Logic update --------- Co-authored-by: “gowridurgad” <“hgowridurgad@github.com>
This commit is contained in:
18
dist/setup/index.js
vendored
18
dist/setup/index.js
vendored
@ -97944,12 +97944,26 @@ const os = __importStar(__nccwpck_require__(857));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(9896));
|
||||
const cache_factory_1 = __nccwpck_require__(665);
|
||||
const utils_1 = __nccwpck_require__(1798);
|
||||
const exec_1 = __nccwpck_require__(5236);
|
||||
function isPyPyVersion(versionSpec) {
|
||||
return versionSpec.startsWith('pypy');
|
||||
}
|
||||
function isGraalPyVersion(versionSpec) {
|
||||
return versionSpec.startsWith('graalpy');
|
||||
}
|
||||
function installPipPackages(pipInstall) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info(`Installing pip packages: ${pipInstall}`);
|
||||
try {
|
||||
const installArgs = pipInstall.trim().split(/\s+/);
|
||||
yield (0, exec_1.exec)('python', ['-m', 'pip', 'install', ...installArgs]);
|
||||
core.info('Successfully installed pip packages');
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(`Failed to install pip packages from "${pipInstall}". Please verify that the package names, versions, or requirements files provided are correct and installable, that the specified packages and versions can be resolved from PyPI or the configured package index, and that your network connection is stable and allows access to the package index.`);
|
||||
}
|
||||
});
|
||||
}
|
||||
function cacheDependencies(cache, pythonVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const cacheDependencyPath = core.getInput('cache-dependency-path') || undefined;
|
||||
@ -98038,6 +98052,10 @@ function run() {
|
||||
if (cache && (0, utils_1.isCacheFeatureAvailable)()) {
|
||||
yield cacheDependencies(cache, pythonVersion);
|
||||
}
|
||||
const pipInstall = core.getInput('pip-install');
|
||||
if (pipInstall) {
|
||||
yield installPipPackages(pipInstall);
|
||||
}
|
||||
}
|
||||
else {
|
||||
core.warning('The `python-version` input is not set. The version of Python currently in `PATH` will be used.');
|
||||
|
Reference in New Issue
Block a user