5
0
mirror of https://gitea.com/actions/setup-python.git synced 2025-10-26 07:16:42 +00:00

Compare commits

...

5 Commits

Author SHA1 Message Date
Tim Felgentreff
cfd55ca824 graalpy: add graalpy early-access and windows builds (#880) 2025-10-22 11:16:57 -05:00
dependabot[bot]
bba65e51ff Bump typescript from 5.4.2 to 5.9.3 and update docs/advanced-usage.md (#1094)
* Bump typescript from 5.4.2 to 5.8.3

Bumps [typescript](https://github.com/microsoft/TypeScript) from 5.4.2 to 5.8.3.
- [Release notes](https://github.com/microsoft/TypeScript/releases)
- [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release-publish.yml)
- [Commits](https://github.com/microsoft/TypeScript/compare/v5.4.2...v5.8.3)

---
updated-dependencies:
- dependency-name: typescript
  dependency-version: 5.8.3
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

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

* Update header text from 'Linux' to 'Ubuntu'

* update target to ES2022

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: priya-kinthali <priya-kinthali@github.com>
2025-10-20 11:11:26 -05:00
Yaroslav Halchenko
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
gowridurgad
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
dependabot[bot]
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
20 changed files with 2117 additions and 2069 deletions

View File

@@ -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

View File

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

View File

@@ -106,7 +106,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu-latest, macos-latest, macos-13] os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v5
- name: Setup GraalPy and check latest - name: Setup GraalPy and check latest

View File

@@ -11,6 +11,13 @@ This action provides the following functionality for GitHub Actions users:
- Optionally caching dependencies for pip, pipenv and poetry - Optionally caching dependencies for pip, pipenv and poetry
- Registering problem matchers for error output - 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 ## Basic usage
See [action.yml](action.yml) 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) - [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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@@ -10,7 +10,7 @@ import * as path from 'path';
import * as semver from 'semver'; import * as semver from 'semver';
import * as finder from '../src/find-graalpy'; import * as finder from '../src/find-graalpy';
import {IGraalPyManifestRelease, IS_WINDOWS} from '../src/utils'; import {IGraalPyManifestRelease} from '../src/utils';
import manifestData from './data/graalpy.json'; import manifestData from './data/graalpy.json';
@@ -19,9 +19,6 @@ const architecture = 'x64';
const toolDir = path.join(__dirname, 'runner', 'tools'); const toolDir = path.join(__dirname, 'runner', 'tools');
const tempDir = path.join(__dirname, 'runner', 'temp'); const tempDir = path.join(__dirname, 'runner', 'temp');
/* GraalPy doesn't have a windows release yet */
const describeSkipOnWindows = IS_WINDOWS ? describe.skip : describe;
describe('parseGraalPyVersion', () => { describe('parseGraalPyVersion', () => {
it.each([ it.each([
['graalpy-23', '23'], ['graalpy-23', '23'],
@@ -108,7 +105,7 @@ describe('findGraalPyToolCache', () => {
}); });
}); });
describeSkipOnWindows('findGraalPyVersion', () => { describe('findGraalPyVersion', () => {
let getBooleanInputSpy: jest.SpyInstance; let getBooleanInputSpy: jest.SpyInstance;
let warningSpy: jest.SpyInstance; let warningSpy: jest.SpyInstance;
let debugSpy: jest.SpyInstance; let debugSpy: jest.SpyInstance;
@@ -358,13 +355,13 @@ describeSkipOnWindows('findGraalPyVersion', () => {
it('found and install successfully, pre-release fallback', async () => { it('found and install successfully, pre-release fallback', async () => {
spyCacheDir = jest.spyOn(tc, 'cacheDir'); spyCacheDir = jest.spyOn(tc, 'cacheDir');
spyCacheDir.mockImplementation(() => spyCacheDir.mockImplementation(() =>
path.join(toolDir, 'GraalPy', '23.1', architecture) path.join(toolDir, 'GraalPy', '24.1', architecture)
); );
spyChmodSync = jest.spyOn(fs, 'chmodSync'); spyChmodSync = jest.spyOn(fs, 'chmodSync');
spyChmodSync.mockImplementation(() => undefined); spyChmodSync.mockImplementation(() => undefined);
await expect( await expect(
finder.findGraalPyVersion( finder.findGraalPyVersion(
'graalpy23.1', 'graalpy24.1',
architecture, architecture,
false, false,
false, false,
@@ -372,7 +369,7 @@ describeSkipOnWindows('findGraalPyVersion', () => {
) )
).rejects.toThrow(); ).rejects.toThrow();
await expect( await expect(
finder.findGraalPyVersion('graalpy23.1', architecture, false, false, true) finder.findGraalPyVersion('graalpy24.1', architecture, false, false, true)
).resolves.toEqual('23.1.0-a.1'); ).resolves.toEqual('24.1.0-ea.9');
}); });
}); });

View File

@@ -21,24 +21,21 @@ const architecture = 'x64';
const toolDir = path.join(__dirname, 'runner', 'tools'); const toolDir = path.join(__dirname, 'runner', 'tools');
const tempDir = path.join(__dirname, 'runner', 'temp'); const tempDir = path.join(__dirname, 'runner', 'temp');
/* GraalPy doesn't have a windows release yet */
const describeSkipOnWindows = IS_WINDOWS ? describe.skip : describe;
describe('graalpyVersionToSemantic', () => { describe('graalpyVersionToSemantic', () => {
it.each([ it.each([
['23.0.0a1', '23.0.0a1'], ['graalpy-24.1.0-ea.09', '24.1.0-ea.9'],
['23.0.0', '23.0.0'], ['graal-23.0.0', '23.0.0'],
['23.0.x', '23.0.x'], ['vm-23.0.x', '23.0.x'],
['23.x', '23.x'] ['graal-23.x', '23.x']
])('%s -> %s', (input, expected) => { ])('%s -> %s', (input, expected) => {
expect(installer.graalPyTagToVersion(input)).toEqual(expected); expect(installer.graalPyTagToVersion(input)).toEqual(expected);
}); });
}); });
describeSkipOnWindows('findRelease', () => { describe('findRelease', () => {
const result = JSON.stringify(manifestData); const result = JSON.stringify(manifestData);
const releases = JSON.parse(result) as IGraalPyManifestRelease[]; const releases = JSON.parse(result) as IGraalPyManifestRelease[];
const extension = 'tar.gz'; const extension = IS_WINDOWS ? 'zip' : 'tar.gz';
const arch = installer.toGraalPyArchitecture(architecture); const arch = installer.toGraalPyArchitecture(architecture);
const platform = installer.toGraalPyPlatform(process.platform); const platform = installer.toGraalPyPlatform(process.platform);
const extensionName = `${platform}-${arch}.${extension}`; const extensionName = `${platform}-${arch}.${extension}`;
@@ -47,8 +44,8 @@ describeSkipOnWindows('findRelease', () => {
browser_download_url: `https://github.com/oracle/graalpython/releases/download/graal-23.0.0/graalpython-23.0.0-${extensionName}` browser_download_url: `https://github.com/oracle/graalpython/releases/download/graal-23.0.0/graalpython-23.0.0-${extensionName}`
}; };
const filesRC1: IGraalPyManifestAsset = { const filesRC1: IGraalPyManifestAsset = {
name: `graalpython-23.1.0a1-${extensionName}`, name: `graalpy-24.1.0-ea.09-${extensionName}`,
browser_download_url: `https://github.com/oracle/graalpython/releases/download/graal-23.1.0a1/graalpython-23.1.0a1-${extensionName}` browser_download_url: `https://github.com/graalvm/graal-languages-ea-builds/releases/download/graalpy-24.1.0-ea.09/graalpy-24.1.0-ea.09-${extensionName}`
}; };
let warningSpy: jest.SpyInstance; let warningSpy: jest.SpyInstance;
@@ -84,15 +81,15 @@ describeSkipOnWindows('findRelease', () => {
}); });
it('Preview version of GraalPy is found', () => { it('Preview version of GraalPy is found', () => {
const graalpyVersion = installer.graalPyTagToVersion('vm-23.1.0a1'); const graalpyVersion = installer.graalPyTagToVersion('vm-24.1.0-ea.09');
expect( expect(
installer.findRelease(releases, graalpyVersion, architecture, false) installer.findRelease(releases, graalpyVersion, architecture, false)
).toMatchObject({ ).toMatchObject({
foundAsset: { foundAsset: {
name: `graalpython-23.1.0a1-${extensionName}`, name: `graalpy-24.1.0-ea.09-${extensionName}`,
browser_download_url: `https://github.com/oracle/graalpython/releases/download/graal-23.1.0a1/graalpython-23.1.0a1-${extensionName}` browser_download_url: `https://github.com/graalvm/graal-languages-ea-builds/releases/download/graalpy-24.1.0-ea.09/graalpy-24.1.0-ea.09-${extensionName}`
}, },
resolvedGraalPyVersion: '23.1.0-a.1' resolvedGraalPyVersion: '24.1.0-ea.9'
}); });
}); });
@@ -107,7 +104,7 @@ describeSkipOnWindows('findRelease', () => {
}); });
it('GraalPy version matches semver (pre-release)', () => { it('GraalPy version matches semver (pre-release)', () => {
const graalpyVersion = '23.1.x'; const graalpyVersion = '24.1.x';
expect( expect(
installer.findRelease(releases, graalpyVersion, architecture, false) installer.findRelease(releases, graalpyVersion, architecture, false)
).toBeNull(); ).toBeNull();
@@ -115,12 +112,12 @@ describeSkipOnWindows('findRelease', () => {
installer.findRelease(releases, graalpyVersion, architecture, true) installer.findRelease(releases, graalpyVersion, architecture, true)
).toMatchObject({ ).toMatchObject({
foundAsset: filesRC1, foundAsset: filesRC1,
resolvedGraalPyVersion: '23.1.0-a.1' resolvedGraalPyVersion: '24.1.0-ea.9'
}); });
}); });
}); });
describeSkipOnWindows('installGraalPy', () => { describe('installGraalPy', () => {
let tcFind: jest.SpyInstance; let tcFind: jest.SpyInstance;
let warningSpy: jest.SpyInstance; let warningSpy: jest.SpyInstance;
let debugSpy: jest.SpyInstance; let debugSpy: jest.SpyInstance;
@@ -232,20 +229,20 @@ describeSkipOnWindows('installGraalPy', () => {
it('found and install GraalPy, pre-release fallback', async () => { it('found and install GraalPy, pre-release fallback', async () => {
spyCacheDir = jest.spyOn(tc, 'cacheDir'); spyCacheDir = jest.spyOn(tc, 'cacheDir');
spyCacheDir.mockImplementation(() => spyCacheDir.mockImplementation(() =>
path.join(toolDir, 'GraalPy', '23.1.0', architecture) path.join(toolDir, 'GraalPy', '24.1.0', architecture)
); );
spyChmodSync = jest.spyOn(fs, 'chmodSync'); spyChmodSync = jest.spyOn(fs, 'chmodSync');
spyChmodSync.mockImplementation(() => undefined); spyChmodSync.mockImplementation(() => undefined);
await expect( await expect(
installer.installGraalPy('23.1.x', architecture, false, undefined) installer.installGraalPy('24.1.x', architecture, false, undefined)
).rejects.toThrow(); ).rejects.toThrow();
await expect( await expect(
installer.installGraalPy('23.1.x', architecture, true, undefined) installer.installGraalPy('24.1.x', architecture, true, undefined)
).resolves.toEqual({ ).resolves.toEqual({
installDir: path.join(toolDir, 'GraalPy', '23.1.0', architecture), installDir: path.join(toolDir, 'GraalPy', '24.1.0', architecture),
resolvedGraalPyVersion: '23.1.0-a.1' resolvedGraalPyVersion: '24.1.0-ea.9'
}); });
expect(spyHttpClient).toHaveBeenCalled(); expect(spyHttpClient).toHaveBeenCalled();

View File

@@ -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."

View File

@@ -87714,22 +87714,23 @@ 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 (mod) { var __importStar = (this && this.__importStar) || (function () {
if (mod && mod.__esModule) return mod; var ownKeys = function(o) {
var result = {}; ownKeys = Object.getOwnPropertyNames || function (o) {
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); var ar = [];
__setModuleDefault(result, mod); for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return result; return ar;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return ownKeys(o);
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } };
return new (P || (P = Promise))(function (resolve, reject) { return function (mod) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } if (mod && mod.__esModule) return mod;
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } var result = {};
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
step((generator = generator.apply(thisArg, _arguments || [])).next()); __setModuleDefault(result, mod);
}); return result;
}; };
})();
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));
@@ -87742,41 +87743,39 @@ var State;
State["CACHE_PATHS"] = "cache-paths"; State["CACHE_PATHS"] = "cache-paths";
})(State || (exports.State = State = {})); })(State || (exports.State = State = {}));
class CacheDistributor { class CacheDistributor {
packageManager;
cacheDependencyPath;
CACHE_KEY_PREFIX = 'setup-python';
constructor(packageManager, cacheDependencyPath) { constructor(packageManager, cacheDependencyPath) {
this.packageManager = packageManager; this.packageManager = packageManager;
this.cacheDependencyPath = cacheDependencyPath; this.cacheDependencyPath = cacheDependencyPath;
this.CACHE_KEY_PREFIX = 'setup-python';
} }
handleLoadedCache() { async handleLoadedCache() { }
return __awaiter(this, void 0, void 0, function* () { }); async restoreCache() {
} const { primaryKey, restoreKey } = await this.computeKeys();
restoreCache() { if (primaryKey.endsWith('-')) {
return __awaiter(this, void 0, void 0, function* () { const file = this.packageManager === 'pip'
const { primaryKey, restoreKey } = yield this.computeKeys(); ? `${this.cacheDependencyPath
if (primaryKey.endsWith('-')) { .split('\n')
const file = this.packageManager === 'pip' .join(',')} or ${constants_1.CACHE_DEPENDENCY_BACKUP_PATH}`
? `${this.cacheDependencyPath : this.cacheDependencyPath.split('\n').join(',');
.split('\n') throw new Error(`No file in ${process.cwd()} matched to [${file}], make sure you have checked out the target repository`);
.join(',')} or ${constants_1.CACHE_DEPENDENCY_BACKUP_PATH}` }
: this.cacheDependencyPath.split('\n').join(','); const cachePath = await this.getCacheGlobalDirectories();
throw new Error(`No file in ${process.cwd()} matched to [${file}], make sure you have checked out the target repository`); core.saveState(State.CACHE_PATHS, cachePath);
} let matchedKey;
const cachePath = yield this.getCacheGlobalDirectories(); try {
core.saveState(State.CACHE_PATHS, cachePath); matchedKey = await cache.restoreCache(cachePath, primaryKey, restoreKey);
let matchedKey; }
try { catch (err) {
matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey); const message = err.message;
} core.info(`[warning]${message}`);
catch (err) { core.setOutput('cache-hit', false);
const message = err.message; return;
core.info(`[warning]${message}`); }
core.setOutput('cache-hit', false); core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
return; await this.handleLoadedCache();
} this.handleMatchResult(matchedKey, primaryKey);
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
yield this.handleLoadedCache();
this.handleMatchResult(matchedKey, primaryKey);
});
} }
handleMatchResult(matchedKey, primaryKey) { handleMatchResult(matchedKey, primaryKey) {
if (matchedKey) { if (matchedKey) {
@@ -87827,27 +87826,28 @@ 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 (mod) { var __importStar = (this && this.__importStar) || (function () {
if (mod && mod.__esModule) return mod; var ownKeys = function(o) {
var result = {}; ownKeys = Object.getOwnPropertyNames || function (o) {
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); var ar = [];
__setModuleDefault(result, mod); for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return result; return ar;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return ownKeys(o);
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } };
return new (P || (P = Promise))(function (resolve, reject) { return function (mod) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } if (mod && mod.__esModule) return mod;
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } var result = {};
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
step((generator = generator.apply(thisArg, _arguments || [])).next()); __setModuleDefault(result, mod);
}); return result;
}; };
})();
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 = void 0; exports.run = run;
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));
@@ -87855,62 +87855,57 @@ 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
function run(earlyExit) { async 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);
}
} }
} }
catch (error) { }
const err = error; catch (error) {
core.setFailed(err.message); const err = error;
} core.setFailed(err.message);
}); }
} }
exports.run = run; async function saveCache(packageManager) {
function saveCache(packageManager) { const cachePathState = core.getState(cache_distributor_1.State.CACHE_PATHS);
return __awaiter(this, void 0, void 0, function* () { if (!cachePathState) {
const cachePathState = core.getState(cache_distributor_1.State.CACHE_PATHS); core.warning('Cache paths are empty. Please check the previous logs and make sure that the python version is specified');
if (!cachePathState) { return;
core.warning('Cache paths are empty. Please check the previous logs and make sure that the python version is specified'); }
return; const cachePaths = JSON.parse(cachePathState);
} core.debug(`paths for caching are ${cachePaths.join(', ')}`);
const cachePaths = JSON.parse(cachePathState); if (!isCacheDirectoryExists(cachePaths)) {
core.debug(`paths for caching are ${cachePaths.join(', ')}`); core.warning(`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${cachePaths.join(', ')}. This likely indicates that there are no dependencies to cache. Consider removing the cache step if it is not needed.`);
if (!isCacheDirectoryExists(cachePaths)) { return;
core.warning(`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${cachePaths.join(', ')}. This likely indicates that there are no dependencies to cache. Consider removing the cache step if it is not needed.`); }
return; const primaryKey = core.getState(cache_distributor_1.State.STATE_CACHE_PRIMARY_KEY);
} const matchedKey = core.getState(cache_distributor_1.State.CACHE_MATCHED_KEY);
const primaryKey = core.getState(cache_distributor_1.State.STATE_CACHE_PRIMARY_KEY); if (!primaryKey) {
const matchedKey = core.getState(cache_distributor_1.State.CACHE_MATCHED_KEY); core.warning('Error retrieving key from state.');
if (!primaryKey) { return;
core.warning('Error retrieving key from state.'); }
return; else if (matchedKey === primaryKey) {
} // no change in target directories
else if (matchedKey === primaryKey) { core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
// no change in target directories return;
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); }
return; let cacheId = 0;
} try {
let cacheId = 0; cacheId = await cache.saveCache(cachePaths, primaryKey);
try { }
cacheId = yield cache.saveCache(cachePaths, primaryKey); catch (err) {
} const message = err.message;
catch (err) { core.info(`[warning]${message}`);
const message = err.message; return;
core.info(`[warning]${message}`); }
return; if (cacheId == -1) {
} return;
if (cacheId == -1) { }
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) => {

2004
dist/setup/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@@ -18,11 +18,12 @@
- [Hosted tool cache](advanced-usage.md#hosted-tool-cache) - [Hosted tool cache](advanced-usage.md#hosted-tool-cache)
- [Using `setup-python` with a self-hosted runner](advanced-usage.md#using-setup-python-with-a-self-hosted-runner) - [Using `setup-python` with a self-hosted runner](advanced-usage.md#using-setup-python-with-a-self-hosted-runner)
- [Windows](advanced-usage.md#windows) - [Windows](advanced-usage.md#windows)
- [Linux](advanced-usage.md#linux) - [Ubuntu](advanced-usage.md#Ubuntu)
- [macOS](advanced-usage.md#macos) - [macOS](advanced-usage.md#macos)
- [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
@@ -577,9 +578,9 @@ If you have a supported self-hosted runner and you would like to use `setup-pyth
>If you are experiencing problems while configuring Python on your self-hosted runner, turn on [step debugging](https://github.com/actions/toolkit/blob/main/docs/action-debugging.md#step-debug-logs) to see additional logs. >If you are experiencing problems while configuring Python on your self-hosted runner, turn on [step debugging](https://github.com/actions/toolkit/blob/main/docs/action-debugging.md#step-debug-logs) to see additional logs.
### Linux ### Ubuntu
By default, the runner downloads and installs tools into the folder set up by `RUNNER_TOOL_CACHE` environment variable. The environment variable called `AGENT_TOOLSDIRECTORY` can be set to change this location for Linux self-hosted runners: By default, the runner downloads and installs tools into the folder set up by `RUNNER_TOOL_CACHE` environment variable. The environment variable called `AGENT_TOOLSDIRECTORY` can be set to change this location for Ubuntu self-hosted runners:
- In the same shell that your runner is using, type `export AGENT_TOOLSDIRECTORY=/path/to/folder`. - In the same shell that your runner is using, type `export AGENT_TOOLSDIRECTORY=/path/to/folder`.
- More permanent way of setting the environment variable is to create an `.env` file in the same directory as your runner and to add `AGENT_TOOLSDIRECTORY=/path/to/folder`. This ensures the variable is always set if your runner is configured as a service. - More permanent way of setting the environment variable is to create an `.env` file in the same directory as your runner and to add `AGENT_TOOLSDIRECTORY=/path/to/folder`. This ensures the variable is always set if your runner is configured as a service.
@@ -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`. 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. 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. 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`). For CPython, `allow-prereleases` will only have effect for `x.y` version range (e.g. `3.14`).
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: 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 ```yaml
jobs: jobs:
test: test:
@@ -642,7 +643,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
os: [Ubuntu, Windows, macOS] os: [Ubuntu, Windows, macOS]
python_version: ["3.11", "3.12", "3.13"] python_version: ["3.14"]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v5
@@ -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.

9
package-lock.json generated
View File

@@ -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.4.2" "typescript": "^5.9.3"
}, },
"engines": { "engines": {
"node": ">=24.0.0" "node": ">=24.0.0"
@@ -5446,10 +5446,11 @@
} }
}, },
"node_modules/typescript": { "node_modules/typescript": {
"version": "5.4.2", "version": "5.9.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.2.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
"integrity": "sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==", "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
"dev": true, "dev": true,
"license": "Apache-2.0",
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
"tsserver": "bin/tsserver" "tsserver": "bin/tsserver"

View File

@@ -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.4.2" "typescript": "^5.9.3"
} }
} }

View File

@@ -1,11 +1,6 @@
import * as path from 'path'; import * as path from 'path';
import * as graalpyInstall from './install-graalpy'; import * as graalpyInstall from './install-graalpy';
import { import {IS_WINDOWS, validateVersion, IGraalPyManifestRelease} from './utils';
IS_WINDOWS,
validateVersion,
IGraalPyManifestRelease,
getBinaryDirectory
} from './utils';
import * as semver from 'semver'; import * as semver from 'semver';
import * as core from '@actions/core'; import * as core from '@actions/core';
@@ -62,11 +57,8 @@ export async function findGraalPyVersion(
const pipDir = IS_WINDOWS ? 'Scripts' : 'bin'; const pipDir = IS_WINDOWS ? 'Scripts' : 'bin';
const _binDir = path.join(installDir, pipDir); const _binDir = path.join(installDir, pipDir);
const binaryExtension = IS_WINDOWS ? '.exe' : ''; const binaryExtension = IS_WINDOWS ? '.exe' : '';
const pythonPath = path.join( const pythonPath = path.join(_binDir, `python${binaryExtension}`);
IS_WINDOWS ? installDir : _binDir, const pythonLocation = path.join(installDir, 'bin');
`python${binaryExtension}`
);
const pythonLocation = getBinaryDirectory(installDir);
if (updateEnvironment) { if (updateEnvironment) {
core.exportVariable('pythonLocation', installDir); core.exportVariable('pythonLocation', installDir);
// https://cmake.org/cmake/help/latest/module/FindPython.html#module:FindPython // https://cmake.org/cmake/help/latest/module/FindPython.html#module:FindPython

View File

@@ -15,7 +15,6 @@ import {
IGraalPyManifestRelease, IGraalPyManifestRelease,
createSymlinkInFolder, createSymlinkInFolder,
isNightlyKeyword, isNightlyKeyword,
getBinaryDirectory,
getNextPageUrl getNextPageUrl
} from './utils'; } from './utils';
@@ -64,7 +63,11 @@ export async function installGraalPy(
const graalpyPath = await tc.downloadTool(downloadUrl, undefined, AUTH); const graalpyPath = await tc.downloadTool(downloadUrl, undefined, AUTH);
core.info('Extracting downloaded archive...'); core.info('Extracting downloaded archive...');
downloadDir = await tc.extractTar(graalpyPath); if (IS_WINDOWS) {
downloadDir = await tc.extractZip(graalpyPath);
} else {
downloadDir = await tc.extractTar(graalpyPath);
}
// root folder in archive can have unpredictable name so just take the first folder // root folder in archive can have unpredictable name so just take the first folder
// downloadDir is unique folder under TEMP and can't contain any other folders // downloadDir is unique folder under TEMP and can't contain any other folders
@@ -81,7 +84,7 @@ export async function installGraalPy(
); );
} }
const binaryPath = getBinaryDirectory(installDir); const binaryPath = path.join(installDir, 'bin');
await createGraalPySymlink(binaryPath, resolvedGraalPyVersion); await createGraalPySymlink(binaryPath, resolvedGraalPyVersion);
await installPip(binaryPath); await installPip(binaryPath);
@@ -115,6 +118,9 @@ export async function getAvailableGraalPyVersions() {
headers.authorization = AUTH; headers.authorization = AUTH;
} }
/*
Get releases first.
*/
let url: string | null = let url: string | null =
'https://api.github.com/repos/oracle/graalpython/releases'; 'https://api.github.com/repos/oracle/graalpython/releases';
const result: IGraalPyManifestRelease[] = []; const result: IGraalPyManifestRelease[] = [];
@@ -130,6 +136,23 @@ export async function getAvailableGraalPyVersions() {
url = getNextPageUrl(response); url = getNextPageUrl(response);
} while (url); } while (url);
/*
Add pre-release builds.
*/
url =
'https://api.github.com/repos/graalvm/graal-languages-ea-builds/releases';
do {
const response: ifm.TypedResponse<IGraalPyManifestRelease[]> =
await http.getJson(url, headers);
if (!response.result) {
throw new Error(
`Unable to retrieve the list of available GraalPy versions from '${url}'`
);
}
result.push(...response.result);
url = getNextPageUrl(response);
} while (url);
return result; return result;
} }
@@ -175,7 +198,8 @@ async function installPip(pythonLocation: string) {
} }
export function graalPyTagToVersion(tag: string) { export function graalPyTagToVersion(tag: string) {
const versionPattern = /.*-(\d+\.\d+\.\d+(?:\.\d+)?)((?:a|b|rc))?(\d*)?/; const versionPattern =
/.*-(\d+\.\d+\.\d+(?:\.\d+)?)(?:-((?:ea|a|b|rc))\.0*(\d+))?/;
const match = tag.match(versionPattern); const match = tag.match(versionPattern);
if (match && match[2]) { if (match && match[2]) {
return `${match[1]}-${match[2]}.${match[3]}`; return `${match[1]}-${match[2]}.${match[3]}`;
@@ -251,10 +275,11 @@ export function findAsset(
) { ) {
const graalpyArch = toGraalPyArchitecture(architecture); const graalpyArch = toGraalPyArchitecture(architecture);
const graalpyPlatform = toGraalPyPlatform(platform); const graalpyPlatform = toGraalPyPlatform(platform);
const graalpyExt = platform == 'win32' ? 'zip' : 'tar.gz';
const found = item.assets.filter( const found = item.assets.filter(
file => file =>
file.name.startsWith('graalpy') && file.name.startsWith('graalpy') &&
file.name.endsWith(`-${graalpyPlatform}-${graalpyArch}.tar.gz`) file.name.endsWith(`-${graalpyPlatform}-${graalpyArch}.${graalpyExt}`)
); );
/* /*
In the future there could be more variants of GraalPy for a single release. Pick the shortest name, that one is the most likely to be the primary variant. In the future there could be more variants of GraalPy for a single release. Pick the shortest name, that one is the most likely to be the primary variant.

View File

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

View File

@@ -379,7 +379,7 @@ export function getVersionInputFromFile(versionFile: string): string[] {
} }
/** /**
* Get the directory containing interpreter binary from installation directory of PyPy or GraalPy * Get the directory containing interpreter binary from installation directory of PyPy
* - 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.
*/ */

View File

@@ -2,7 +2,7 @@
"compilerOptions": { "compilerOptions": {
/* Basic Options */ /* Basic Options */
// "incremental": true, /* Enable incremental compilation */ // "incremental": true, /* Enable incremental compilation */
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "target": "ES2022", /* 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. */