Compare commits

...

5 Commits

Author SHA1 Message Date
1565e1db2c updated README for pip-install 2025-10-16 14:23:45 +05:30
5437d3a38f Bump actions/publish-action from 0.3.0 to 0.4.0
Bumps [actions/publish-action](https://github.com/actions/publish-action) from 0.3.0 to 0.4.0.
- [Commits](https://github.com/actions/publish-action/compare/v0.3.0...v0.4.0)

---
updated-dependencies:
- dependency-name: actions/publish-action
  dependency-version: 0.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-16 08:22:15 +00:00
18566f86b3 Improve wording and "fix example" (remove 3.13) on testing against pre-release (#979)
* Improve wording and "fix example" (remove 3.13) on testing against pre-releases

3.13 was added in a mass tune up in 0b93645e9f , without
adjusting the wording. With 3.13 listed there too, example does not really make much
sense. So I decided to make it explicit in wording and remove 3.13, so whenever next
refactoring to add 3.14 to be added to every line where 3.13 is -- this would not
even come to attention

* Update to use 3.14 not 3.12 as an example for pre-release
2025-10-14 11:42:06 -05:00
2e3e4b15a8 Add support for pip-install input (#1201)
* Add pip-install input

* Improve error message

* Logic update

---------

Co-authored-by: “gowridurgad” <“hgowridurgad@github.com>
2025-09-25 22:01:19 -05:00
4267e283df Bump urllib3 from 1.26.19 to 2.5.0 in /__tests__/data and document breaking changes in v6 (#1139)
* Bump urllib3 from 1.26.19 to 2.5.0 in /__tests__/data

Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.26.19 to 2.5.0.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](https://github.com/urllib3/urllib3/compare/1.26.19...2.5.0)

---
updated-dependencies:
- dependency-name: urllib3
  dependency-version: 2.5.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* documentation update

* doc update

* doc update

* doc format update

* doc update

* doc update

* doc update

* fix check failures

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Aparna Jyothi <aparnajyothi-y@github.com>
2025-09-17 22:06:08 -05:00
10 changed files with 183 additions and 6 deletions

View File

@ -219,3 +219,56 @@ jobs:
pip-version: '25.0.1'
- name: Install dependencies
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

View File

@ -45,6 +45,9 @@ jobs:
exclude:
- os: windows-latest
python-version: pypy-3.11-v7.x
- os: macos-latest
python-version: pypy-3.9-v7.x
steps:
- uses: actions/checkout@v5
- name: Setup Python
@ -183,6 +186,8 @@ jobs:
exclude:
- os: windows-latest
python-version: pypy-3.11-v7.x
- os: macos-latest
python-version: pypy-3.9-v7.x
steps:
- uses: actions/checkout@v5
- name: Setup Python
@ -306,3 +311,56 @@ jobs:
pip-version: '25.0.1'
- name: Install dependencies
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

View File

@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Update the ${{ env.TAG_NAME }} tag
uses: actions/publish-action@v0.3.0
uses: actions/publish-action@v0.4.0
with:
source-tag: ${{ env.TAG_NAME }}
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}

View File

@ -11,6 +11,13 @@ This action provides the following functionality for GitHub Actions users:
- Optionally caching dependencies for pip, pipenv and poetry
- Registering problem matchers for error output
## Breaking changes in V6
- Upgraded action from node20 to node24
> Make sure your runner is on version v2.327.1 or later to ensure compatibility with this release. See [Release Notes](https://github.com/actions/runner/releases/tag/v2.327.1)
For more details, see the full release notes on the [releases page](https://github.com/actions/setup-python/releases/tag/v6.0.0)
## Basic usage
See [action.yml](action.yml)
@ -111,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)
- [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-install input](docs/advanced-usage.md#using-the-pip-install-input)
## Recommended permissions

View File

@ -8,5 +8,5 @@ packaging==20.7
pdf2image==1.12.1
Pygments==2.6.1
requests==2.32.2
urllib3==1.26.19
urllib3==2.5.0
xlrd==1.2.0

View File

@ -42,6 +42,6 @@ pywin32-ctypes==0.2.0
requests==2.32.2
urllib3==1.26.19
urllib3==2.5.0
xlrd==1.2.0

View File

@ -31,6 +31,8 @@ inputs:
default: false
pip-version:
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:
python-version:
description: "The installed Python or PyPy version. Useful when given a version range as input."

18
dist/setup/index.js vendored
View File

@ -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.');

View File

@ -23,6 +23,7 @@
- [Using `setup-python` on GHES](advanced-usage.md#using-setup-python-on-ghes)
- [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-install input](advanced-usage.md#using-the-pip-install-input)
## Using the `python-version` input
@ -631,8 +632,8 @@ If the runner is not able to access github.com, any Python versions requested du
The `allow-prereleases` flag defaults to `false`.
If `allow-prereleases` is set to `true`, the action will allow falling back to pre-release versions of Python when a matching GA version of Python is not available.
This allows for example to simplify reuse of `python-version` as an input of nox for pre-releases of Python by not requiring manipulation of the `3.y-dev` specifier.
For CPython, `allow-prereleases` will only have effect for `x.y` version range (e.g. `3.12`).
Let's say that python 3.12 is not generally available, the following workflow will fallback to the most recent pre-release of python 3.12:
For CPython, `allow-prereleases` will only have effect for `x.y` version range (e.g. `3.14`).
Let's say that in the past, when python 3.14 was not yet generally available, the following workflow would have fallback to the most recent pre-release of python 3.14:
```yaml
jobs:
test:
@ -642,7 +643,7 @@ jobs:
fail-fast: false
matrix:
os: [Ubuntu, Windows, macOS]
python_version: ["3.11", "3.12", "3.13"]
python_version: ["3.14"]
steps:
- uses: actions/checkout@v5
@ -672,3 +673,22 @@ 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.
> 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.
> The `pip-install` input mirrors the flexibility of a standard pip install command and supports most of its arguments.

View File

@ -13,6 +13,7 @@ import {
getVersionInputFromFile,
getVersionsInputFromPlainFile
} from './utils';
import {exec} from '@actions/exec';
function isPyPyVersion(versionSpec: string) {
return versionSpec.startsWith('pypy');
@ -22,6 +23,19 @@ function isGraalPyVersion(versionSpec: string) {
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) {
const cacheDependencyPath =
core.getInput('cache-dependency-path') || undefined;
@ -145,6 +159,10 @@ async function run() {
if (cache && isCacheFeatureAvailable()) {
await cacheDependencies(cache, pythonVersion);
}
const pipInstall = core.getInput('pip-install');
if (pipInstall) {
await installPipPackages(pipInstall);
}
} else {
core.warning(
'The `python-version` input is not set. The version of Python currently in `PATH` will be used.'