Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e348410
Remove Ubuntu 20.04 from workflows due to deprecation from 2025-04-15…
v-aparnajyothi-y Apr 11, 2025
6ed2c67
Fix for Candidate Not Iterable Error (#1082)
v-aparnajyothi-y Apr 17, 2025
5d95bc1
Bump semver and @types/semver (#1091)
dependabot[bot] Apr 22, 2025
30eafe9
Bump prettier from 2.8.8 to 3.5.3 (#1046)
dependabot[bot] Apr 22, 2025
a26af69
Bump ts-jest from 29.1.2 to 29.3.2 (#1081)
dependabot[bot] Apr 24, 2025
5db1cf9
Enhance reading from .python-version (#787)
krystof-k May 21, 2025
5fa0ee6
Bump @actions/tool-cache from 2.0.1 to 2.0.2 (#1095)
dependabot[bot] Jun 18, 2025
e9c40fb
Add support for `pip-version` (#1129)
v-priyagupta108 Jun 20, 2025
1264885
Enhance cache-dependency-path handling to support files outside the w…
v-aparnajyothi-y Jun 25, 2025
532b046
Add Architecture-Specific PATH Management for Python with --user Flag…
v-aparnajyothi-y Jul 3, 2025
88ffd4d
Include python version in PyPy python-version output (#1110)
cdce8p Jul 21, 2025
3c6f142
update documentation (#1156)
v-priya-kinthali Jul 23, 2025
36da51d
Add version parsing from Pipfile (#1067)
aradkdj Jul 24, 2025
03bb615
Bump idna from 2.9 to 3.7 in /__tests__/data (#843)
dependabot[bot] Jul 29, 2025
fbeb884
Bump form-data to fix critical vulnerabilities #182 & #183 (#1163)
v-aparnajyothi-y Jul 30, 2025
9322b3c
Upgrade setuptools to 78.1.1 to fix path traversal vulnerability in P…
v-aparnajyothi-y Aug 4, 2025
f62a0e2
Change missing cache directory error to warning (#1182)
v-aparnajyothi-y Aug 26, 2025
5b668cf
Bump actions/checkout from 4 to 5 (#1181)
dependabot[bot] Aug 26, 2025
65b0712
Clarify pythonLocation behavior for PyPy and GraalPy in environment v…
v-aparnajyothi-y Aug 26, 2025
3d1e2d2
Revert "Enhance cache-dependency-path handling to support files outsi…
v-aparnajyothi-y Aug 28, 2025
e797f83
Upgrade to node 24 (#1164)
salmanmkc Sep 4, 2025
4267e28
Bump urllib3 from 1.26.19 to 2.5.0 in /__tests__/data and document br…
dependabot[bot] Sep 18, 2025
2e3e4b1
Add support for pip-install input (#1201)
v-gowridurgad Sep 26, 2025
18566f8
Improve wording and "fix example" (remove 3.13) on testing against pr…
yarikoptic Oct 14, 2025
bba65e5
Bump typescript from 5.4.2 to 5.9.3 and update docs/advanced-usage.md…
dependabot[bot] Oct 20, 2025
cfd55ca
graalpy: add graalpy early-access and windows builds (#880)
timfel Oct 22, 2025
443da59
Bump actions/publish-action from 0.3.0 to 0.4.0 & Documentation updat…
dependabot[bot] Nov 12, 2025
97aeb3e
Bump requests from 2.32.2 to 2.32.4 in /__tests__/data (#1130)
dependabot[bot] Nov 13, 2025
bfc4944
Bump prettier from 3.5.3 to 3.6.2 (#1234)
dependabot[bot] Nov 18, 2025
83679a8
Bump @types/node from 24.1.0 to 24.9.1 and update macos-13 to macos-1…
dependabot[bot] Nov 24, 2025
4f41a90
Bump urllib3 from 2.5.0 to 2.6.0 in /__tests__/data (#1253)
dependabot[bot] Dec 30, 2025
bfe8cc5
Upgrade @actions dependencies to Node 24 compatible versions (#1259)
salmanmkc Jan 20, 2026
a309ff8
Bump urllib3 from 2.6.0 to 2.6.3 in /__tests__/data (#1264)
dependabot[bot] Jan 22, 2026
918d5f3
Merge tag 'v6.2.0' into sync/upstream-v6.2.0
guptaankit015 Mar 26, 2026
80339e6
chore: rebuild dist and lockfile after upstream sync
guptaankit015 Mar 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add support for pip-install input (actions#1201)
* Add pip-install input

* Improve error message

* Logic update

---------

Co-authored-by: “gowridurgad” <“hgowridurgad@github.com>
  • Loading branch information
v-gowridurgad and “gowridurgad” authored Sep 26, 2025
commit 2e3e4b15a884dc73a63f962bff250a855150a234
53 changes: 53 additions & 0 deletions .github/workflows/e2e-cache-freethreaded.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
53 changes: 53 additions & 0 deletions .github/workflows/e2e-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -311,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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
- [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

Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
18 changes: 18 additions & 0 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.');
Expand Down
18 changes: 18 additions & 0 deletions docs/advanced-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.

> 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.
18 changes: 18 additions & 0 deletions src/setup-python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
getVersionInputFromFile,
getVersionsInputFromPlainFile
} from './utils';
import {exec} from '@actions/exec';

function isPyPyVersion(versionSpec: string) {
return versionSpec.startsWith('pypy');
Expand All @@ -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;
Expand Down Expand Up @@ -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.'
Expand Down