mirror of
https://github.com/actions/setup-python.git
synced 2026-01-14 22:18:20 +00:00
Compare commits
2 Commits
4e05d63840
...
c3739a195c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3739a195c | ||
|
|
2e3e4b15a8 |
53
.github/workflows/e2e-cache-freethreaded.yml
vendored
53
.github/workflows/e2e-cache-freethreaded.yml
vendored
@@ -219,3 +219,56 @@ jobs:
|
|||||||
pip-version: '25.0.1'
|
pip-version: '25.0.1'
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pip install numpy pandas requests
|
run: pip install numpy pandas requests
|
||||||
|
|
||||||
|
python-pip-dependencies-caching-with-pip-install:
|
||||||
|
name: Test pip (Python ${{ matrix.python-version}}, ${{ matrix.os }})
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
[
|
||||||
|
ubuntu-latest,
|
||||||
|
ubuntu-22.04,
|
||||||
|
ubuntu-24.04-arm,
|
||||||
|
ubuntu-22.04-arm,
|
||||||
|
windows-latest,
|
||||||
|
macos-latest,
|
||||||
|
macos-13
|
||||||
|
]
|
||||||
|
python-version: [3.13.0t, 3.13.1t, 3.13.2t]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- name: Setup Python
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
cache: 'pip'
|
||||||
|
pip-install: numpy pandas requests
|
||||||
|
|
||||||
|
python-pip-dependencies-caching-path-with-pip-install:
|
||||||
|
name: Test pip (Python ${{ matrix.python-version}}, ${{ matrix.os }}, caching path)
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
[
|
||||||
|
ubuntu-latest,
|
||||||
|
ubuntu-22.04,
|
||||||
|
ubuntu-24.04-arm,
|
||||||
|
ubuntu-22.04-arm,
|
||||||
|
windows-latest,
|
||||||
|
macos-latest,
|
||||||
|
macos-13
|
||||||
|
]
|
||||||
|
python-version: [3.13.0t, 3.13.1t, 3.13.2t]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- name: Setup Python
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
cache: 'pip'
|
||||||
|
cache-dependency-path: __tests__/data/requirements.txt
|
||||||
|
pip-install: numpy pandas requests
|
||||||
|
|||||||
53
.github/workflows/e2e-cache.yml
vendored
53
.github/workflows/e2e-cache.yml
vendored
@@ -311,3 +311,56 @@ jobs:
|
|||||||
pip-version: '25.0.1'
|
pip-version: '25.0.1'
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pip install numpy pandas requests
|
run: pip install numpy pandas requests
|
||||||
|
|
||||||
|
python-pip-dependencies-caching-with-pip-install:
|
||||||
|
name: Test pip (Python ${{ matrix.python-version}}, ${{ matrix.os }})
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
[
|
||||||
|
ubuntu-latest,
|
||||||
|
ubuntu-24.04-arm,
|
||||||
|
ubuntu-22.04,
|
||||||
|
ubuntu-22.04-arm,
|
||||||
|
windows-latest,
|
||||||
|
macos-latest,
|
||||||
|
macos-13
|
||||||
|
]
|
||||||
|
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- name: Setup Python
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
cache: 'pip'
|
||||||
|
pip-install: numpy pandas requests
|
||||||
|
|
||||||
|
python-pip-dependencies-caching-path-with-pip-install:
|
||||||
|
name: Test pip (Python ${{ matrix.python-version}}, ${{ matrix.os }}, caching path)
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
[
|
||||||
|
ubuntu-latest,
|
||||||
|
ubuntu-24.04-arm,
|
||||||
|
ubuntu-22.04,
|
||||||
|
ubuntu-22.04-arm,
|
||||||
|
windows-latest,
|
||||||
|
macos-latest,
|
||||||
|
macos-13
|
||||||
|
]
|
||||||
|
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- name: Setup Python
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
cache: 'pip'
|
||||||
|
cache-dependency-path: __tests__/data/requirements.txt
|
||||||
|
pip-install: numpy pandas requests
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ See examples of using `cache` and `cache-dependency-path` for `pipenv` and `poet
|
|||||||
- [Using `setup-python` on GHES](docs/advanced-usage.md#using-setup-python-on-ghes)
|
- [Using `setup-python` on GHES](docs/advanced-usage.md#using-setup-python-on-ghes)
|
||||||
- [Allow pre-releases](docs/advanced-usage.md#allow-pre-releases)
|
- [Allow pre-releases](docs/advanced-usage.md#allow-pre-releases)
|
||||||
- [Using the pip-version input](docs/advanced-usage.md#using-the-pip-version-input)
|
- [Using the pip-version input](docs/advanced-usage.md#using-the-pip-version-input)
|
||||||
|
- [Using the pip-install input](docs/advanced-usage.md#using-the-pip-install-input)
|
||||||
|
|
||||||
## Recommended permissions
|
## Recommended permissions
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ inputs:
|
|||||||
default: false
|
default: false
|
||||||
pip-version:
|
pip-version:
|
||||||
description: "Used to specify the version of pip to install with the Python. Supported format: major[.minor][.patch]."
|
description: "Used to specify the version of pip to install with the Python. Supported format: major[.minor][.patch]."
|
||||||
|
pip-install:
|
||||||
|
description: "Used to specify the packages to install with pip after setting up Python. Can be a requirements file or package names."
|
||||||
outputs:
|
outputs:
|
||||||
python-version:
|
python-version:
|
||||||
description: "The installed Python or PyPy version. Useful when given a version range as input."
|
description: "The installed Python or PyPy version. Useful when given a version range as input."
|
||||||
|
|||||||
77
dist/cache-save/index.js
vendored
77
dist/cache-save/index.js
vendored
@@ -87714,23 +87714,22 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || (function () {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
var ownKeys = function(o) {
|
|
||||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
||||||
var ar = [];
|
|
||||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
||||||
return ar;
|
|
||||||
};
|
|
||||||
return ownKeys(o);
|
|
||||||
};
|
|
||||||
return function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
})();
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
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 step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.State = void 0;
|
exports.State = void 0;
|
||||||
const cache = __importStar(__nccwpck_require__(5116));
|
const cache = __importStar(__nccwpck_require__(5116));
|
||||||
@@ -87748,9 +87747,12 @@ class CacheDistributor {
|
|||||||
this.cacheDependencyPath = cacheDependencyPath;
|
this.cacheDependencyPath = cacheDependencyPath;
|
||||||
this.CACHE_KEY_PREFIX = 'setup-python';
|
this.CACHE_KEY_PREFIX = 'setup-python';
|
||||||
}
|
}
|
||||||
async handleLoadedCache() { }
|
handleLoadedCache() {
|
||||||
async restoreCache() {
|
return __awaiter(this, void 0, void 0, function* () { });
|
||||||
const { primaryKey, restoreKey } = await this.computeKeys();
|
}
|
||||||
|
restoreCache() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const { primaryKey, restoreKey } = yield this.computeKeys();
|
||||||
if (primaryKey.endsWith('-')) {
|
if (primaryKey.endsWith('-')) {
|
||||||
const file = this.packageManager === 'pip'
|
const file = this.packageManager === 'pip'
|
||||||
? `${this.cacheDependencyPath
|
? `${this.cacheDependencyPath
|
||||||
@@ -87759,11 +87761,11 @@ class CacheDistributor {
|
|||||||
: this.cacheDependencyPath.split('\n').join(',');
|
: this.cacheDependencyPath.split('\n').join(',');
|
||||||
throw new Error(`No file in ${process.cwd()} matched to [${file}], make sure you have checked out the target repository`);
|
throw new Error(`No file in ${process.cwd()} matched to [${file}], make sure you have checked out the target repository`);
|
||||||
}
|
}
|
||||||
const cachePath = await this.getCacheGlobalDirectories();
|
const cachePath = yield this.getCacheGlobalDirectories();
|
||||||
core.saveState(State.CACHE_PATHS, cachePath);
|
core.saveState(State.CACHE_PATHS, cachePath);
|
||||||
let matchedKey;
|
let matchedKey;
|
||||||
try {
|
try {
|
||||||
matchedKey = await cache.restoreCache(cachePath, primaryKey, restoreKey);
|
matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
const message = err.message;
|
const message = err.message;
|
||||||
@@ -87772,8 +87774,9 @@ class CacheDistributor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
|
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
|
||||||
await this.handleLoadedCache();
|
yield this.handleLoadedCache();
|
||||||
this.handleMatchResult(matchedKey, primaryKey);
|
this.handleMatchResult(matchedKey, primaryKey);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
handleMatchResult(matchedKey, primaryKey) {
|
handleMatchResult(matchedKey, primaryKey) {
|
||||||
if (matchedKey) {
|
if (matchedKey) {
|
||||||
@@ -87824,28 +87827,27 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || (function () {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
var ownKeys = function(o) {
|
|
||||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
||||||
var ar = [];
|
|
||||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
||||||
return ar;
|
|
||||||
};
|
|
||||||
return ownKeys(o);
|
|
||||||
};
|
|
||||||
return function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
})();
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
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 step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
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.run = run;
|
exports.run = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(7484));
|
const core = __importStar(__nccwpck_require__(7484));
|
||||||
const cache = __importStar(__nccwpck_require__(5116));
|
const cache = __importStar(__nccwpck_require__(5116));
|
||||||
const fs_1 = __importDefault(__nccwpck_require__(9896));
|
const fs_1 = __importDefault(__nccwpck_require__(9896));
|
||||||
@@ -87853,11 +87855,12 @@ const cache_distributor_1 = __nccwpck_require__(2326);
|
|||||||
// Added early exit to resolve issue with slow post action step:
|
// Added early exit to resolve issue with slow post action step:
|
||||||
// - https://github.com/actions/setup-node/issues/878
|
// - https://github.com/actions/setup-node/issues/878
|
||||||
// https://github.com/actions/cache/pull/1217
|
// https://github.com/actions/cache/pull/1217
|
||||||
async function run(earlyExit) {
|
function run(earlyExit) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const cache = core.getInput('cache');
|
const cache = core.getInput('cache');
|
||||||
if (cache) {
|
if (cache) {
|
||||||
await saveCache(cache);
|
yield saveCache(cache);
|
||||||
if (earlyExit) {
|
if (earlyExit) {
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
@@ -87867,8 +87870,11 @@ async function run(earlyExit) {
|
|||||||
const err = error;
|
const err = error;
|
||||||
core.setFailed(err.message);
|
core.setFailed(err.message);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
async function saveCache(packageManager) {
|
exports.run = run;
|
||||||
|
function saveCache(packageManager) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const cachePathState = core.getState(cache_distributor_1.State.CACHE_PATHS);
|
const cachePathState = core.getState(cache_distributor_1.State.CACHE_PATHS);
|
||||||
if (!cachePathState) {
|
if (!cachePathState) {
|
||||||
core.warning('Cache paths are empty. Please check the previous logs and make sure that the python version is specified');
|
core.warning('Cache paths are empty. Please check the previous logs and make sure that the python version is specified');
|
||||||
@@ -87893,7 +87899,7 @@ async function saveCache(packageManager) {
|
|||||||
}
|
}
|
||||||
let cacheId = 0;
|
let cacheId = 0;
|
||||||
try {
|
try {
|
||||||
cacheId = await cache.saveCache(cachePaths, primaryKey);
|
cacheId = yield cache.saveCache(cachePaths, primaryKey);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
const message = err.message;
|
const message = err.message;
|
||||||
@@ -87904,6 +87910,7 @@ async function saveCache(packageManager) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
core.info(`Cache saved with the key: ${primaryKey}`);
|
core.info(`Cache saved with the key: ${primaryKey}`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
function isCacheDirectoryExists(cacheDirectory) {
|
function isCacheDirectoryExists(cacheDirectory) {
|
||||||
const result = cacheDirectory.reduce((previousValue, currentValue) => {
|
const result = cacheDirectory.reduce((previousValue, currentValue) => {
|
||||||
|
|||||||
707
dist/setup/index.js
vendored
707
dist/setup/index.js
vendored
File diff suppressed because it is too large
Load Diff
@@ -23,6 +23,7 @@
|
|||||||
- [Using `setup-python` on GHES](advanced-usage.md#using-setup-python-on-ghes)
|
- [Using `setup-python` on GHES](advanced-usage.md#using-setup-python-on-ghes)
|
||||||
- [Allow pre-releases](advanced-usage.md#allow-pre-releases)
|
- [Allow pre-releases](advanced-usage.md#allow-pre-releases)
|
||||||
- [Using the pip-version input](advanced-usage.md#using-the-pip-version-input)
|
- [Using the pip-version input](advanced-usage.md#using-the-pip-version-input)
|
||||||
|
- [Using the pip-install input](advanced-usage.md#using-the-pip-install-input)
|
||||||
|
|
||||||
## Using the `python-version` input
|
## Using the `python-version` input
|
||||||
|
|
||||||
@@ -672,3 +673,20 @@ The version of Pip should be specified in the format `major`, `major.minor`, or
|
|||||||
> The `pip-version` input is supported only with standard Python versions. It is not available when using PyPy or GraalPy.
|
> The `pip-version` input is supported only with standard Python versions. It is not available when using PyPy or GraalPy.
|
||||||
|
|
||||||
> Using a specific or outdated version of pip may result in compatibility or security issues and can cause job failures. For best practices and guidance, refer to the official [pip documentation](https://pip.pypa.io/en/stable/).
|
> Using a specific or outdated version of pip may result in compatibility or security issues and can cause job failures. For best practices and guidance, refer to the official [pip documentation](https://pip.pypa.io/en/stable/).
|
||||||
|
|
||||||
|
## Using the pip-install input
|
||||||
|
|
||||||
|
The `pip-install` input allows you to install dependencies as part of the Python setup step.
|
||||||
|
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v6
|
||||||
|
with:
|
||||||
|
python-version: '3.13'
|
||||||
|
pip-install: -r requirements.txt
|
||||||
|
```
|
||||||
|
> Note: This feature is intended for standard pip-based dependency installations.
|
||||||
|
For complex workflows, or alternative package managers (e.g., poetry, pipenv), we recommend using separate steps to maintain clarity and flexibility.
|
||||||
|
|||||||
8
package-lock.json
generated
8
package-lock.json
generated
@@ -34,7 +34,7 @@
|
|||||||
"jest-circus": "^29.7.0",
|
"jest-circus": "^29.7.0",
|
||||||
"prettier": "^3.5.3",
|
"prettier": "^3.5.3",
|
||||||
"ts-jest": "^29.3.2",
|
"ts-jest": "^29.3.2",
|
||||||
"typescript": "^5.9.2"
|
"typescript": "^5.9.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=24.0.0"
|
"node": ">=24.0.0"
|
||||||
@@ -5446,9 +5446,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/typescript": {
|
"node_modules/typescript": {
|
||||||
"version": "5.9.2",
|
"version": "5.9.3",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
||||||
"integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==",
|
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
@@ -53,6 +53,6 @@
|
|||||||
"jest-circus": "^29.7.0",
|
"jest-circus": "^29.7.0",
|
||||||
"prettier": "^3.5.3",
|
"prettier": "^3.5.3",
|
||||||
"ts-jest": "^29.3.2",
|
"ts-jest": "^29.3.2",
|
||||||
"typescript": "^5.9.2"
|
"typescript": "^5.9.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
getVersionInputFromFile,
|
getVersionInputFromFile,
|
||||||
getVersionsInputFromPlainFile
|
getVersionsInputFromPlainFile
|
||||||
} from './utils';
|
} from './utils';
|
||||||
|
import {exec} from '@actions/exec';
|
||||||
|
|
||||||
function isPyPyVersion(versionSpec: string) {
|
function isPyPyVersion(versionSpec: string) {
|
||||||
return versionSpec.startsWith('pypy');
|
return versionSpec.startsWith('pypy');
|
||||||
@@ -22,6 +23,19 @@ function isGraalPyVersion(versionSpec: string) {
|
|||||||
return versionSpec.startsWith('graalpy');
|
return versionSpec.startsWith('graalpy');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function installPipPackages(pipInstall: string) {
|
||||||
|
core.info(`Installing pip packages: ${pipInstall}`);
|
||||||
|
try {
|
||||||
|
const installArgs = pipInstall.trim().split(/\s+/);
|
||||||
|
await 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.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function cacheDependencies(cache: string, pythonVersion: string) {
|
async function cacheDependencies(cache: string, pythonVersion: string) {
|
||||||
const cacheDependencyPath =
|
const cacheDependencyPath =
|
||||||
core.getInput('cache-dependency-path') || undefined;
|
core.getInput('cache-dependency-path') || undefined;
|
||||||
@@ -145,6 +159,10 @@ async function run() {
|
|||||||
if (cache && isCacheFeatureAvailable()) {
|
if (cache && isCacheFeatureAvailable()) {
|
||||||
await cacheDependencies(cache, pythonVersion);
|
await cacheDependencies(cache, pythonVersion);
|
||||||
}
|
}
|
||||||
|
const pipInstall = core.getInput('pip-install');
|
||||||
|
if (pipInstall) {
|
||||||
|
await installPipPackages(pipInstall);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
core.warning(
|
core.warning(
|
||||||
'The `python-version` input is not set. The version of Python currently in `PATH` will be used.'
|
'The `python-version` input is not set. The version of Python currently in `PATH` will be used.'
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
/* Basic Options */
|
/* Basic Options */
|
||||||
// "incremental": true, /* Enable incremental compilation */
|
// "incremental": true, /* Enable incremental compilation */
|
||||||
"target": "es2018", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||||
// "checkJs": true, /* Report errors in .js files. */
|
// "checkJs": true, /* Report errors in .js files. */
|
||||||
|
|||||||
Reference in New Issue
Block a user