Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit abfae9a

Browse filesBrowse files
committed
update to v4, remove python-version default
* python-version overrides python-version-file, like setup-node * checks '.python-version' by default if nothing else specified
1 parent dbfda6e commit abfae9a
Copy full SHA for abfae9a

File tree

Expand file treeCollapse file tree

4 files changed

+38
-31
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+38
-31
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+15-15Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# setup-python V3
1+
# setup-python v4
22

33
<p align="left">
44
<a href="https://github.com/actions/setup-python"><img alt="GitHub Actions status" src="https://github.com/actions/setup-python/workflows/Main%20workflow/badge.svg"></a>
@@ -30,7 +30,7 @@ Basic:
3030
```yaml
3131
steps:
3232
- uses: actions/checkout@v3
33-
- uses: actions/setup-python@v3
33+
- uses: actions/setup-python@v4
3434
with:
3535
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
3636
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
@@ -40,8 +40,8 @@ steps:
4040
Read Python version from file:
4141
```yaml
4242
steps:
43-
- uses: actions/checkout@v2
44-
- uses: actions/setup-python@v2
43+
- uses: actions/checkout@v3
44+
- uses: actions/setup-python@v4
4545
with:
4646
python-version-file: '.python-version' # Read python version from a file
4747
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
@@ -60,7 +60,7 @@ jobs:
6060
steps:
6161
- uses: actions/checkout@v3
6262
- name: Set up Python
63-
uses: actions/setup-python@v3
63+
uses: actions/setup-python@v4
6464
with:
6565
python-version: ${{ matrix.python-version }}
6666
architecture: x64
@@ -84,7 +84,7 @@ jobs:
8484
steps:
8585
- uses: actions/checkout@v3
8686
- name: Set up Python
87-
uses: actions/setup-python@v3
87+
uses: actions/setup-python@v4
8888
with:
8989
python-version: ${{ matrix.python-version }}
9090
- name: Display Python version
@@ -102,7 +102,7 @@ jobs:
102102
python-version: ['3.7.4', '3.8', '3.9', '3.10']
103103
steps:
104104
- uses: actions/checkout@v3
105-
- uses: actions/setup-python@v3
105+
- uses: actions/setup-python@v4
106106
with:
107107
python-version: ${{ matrix.python-version }}
108108
- run: python my_script.py
@@ -112,7 +112,7 @@ Download and set up an accurate pre-release version of Python:
112112
```yaml
113113
steps:
114114
- uses: actions/checkout@v3
115-
- uses: actions/setup-python@v3
115+
- uses: actions/setup-python@v4
116116
with:
117117
python-version: '3.11.0-alpha.1'
118118
- run: python my_script.py
@@ -122,7 +122,7 @@ Download and set up the latest available version of Python (includes both pre-re
122122
```yaml
123123
steps:
124124
- uses: actions/checkout@v3
125-
- uses: actions/setup-python@v3
125+
- uses: actions/setup-python@v4
126126
with:
127127
python-version: '3.11.0-alpha - 3.11.0' # SemVer's version range syntax
128128
- run: python my_script.py
@@ -142,7 +142,7 @@ jobs:
142142
- 'pypy-3.8' # the latest available version of PyPy that supports Python 3.8
143143
steps:
144144
- uses: actions/checkout@v3
145-
- uses: actions/setup-python@v3
145+
- uses: actions/setup-python@v4
146146
with:
147147
python-version: ${{ matrix.python-version }}
148148
- run: python my_script.py
@@ -241,7 +241,7 @@ The requirements file format allows to specify dependency versions using logical
241241
```yaml
242242
steps:
243243
- uses: actions/checkout@v3
244-
- uses: actions/setup-python@v3
244+
- uses: actions/setup-python@v4
245245
with:
246246
python-version: '3.9'
247247
cache: 'pip'
@@ -254,7 +254,7 @@ steps:
254254
- uses: actions/checkout@v3
255255
- name: Install pipenv
256256
run: pipx install pipenv
257-
- uses: actions/setup-python@v3
257+
- uses: actions/setup-python@v4
258258
with:
259259
python-version: '3.9'
260260
cache: 'pipenv'
@@ -267,7 +267,7 @@ steps:
267267
- uses: actions/checkout@v3
268268
- name: Install poetry
269269
run: pipx install poetry
270-
- uses: actions/setup-python@v3
270+
- uses: actions/setup-python@v4
271271
with:
272272
python-version: '3.9'
273273
cache: 'poetry'
@@ -279,7 +279,7 @@ steps:
279279
```yaml
280280
steps:
281281
- uses: actions/checkout@v3
282-
- uses: actions/setup-python@v3
282+
- uses: actions/setup-python@v4
283283
with:
284284
python-version: '3.9'
285285
cache: 'pip'
@@ -293,7 +293,7 @@ steps:
293293
- uses: actions/checkout@v3
294294
- name: Install pipenv
295295
run: pipx install pipenv
296-
- uses: actions/setup-python@v3
296+
- uses: actions/setup-python@v4
297297
with:
298298
python-version: '3.9'
299299
cache: 'pipenv'

‎action.yml

Copy file name to clipboardExpand all lines: action.yml
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ description: 'Set up a specific version of Python and add the command-line tools
44
author: 'GitHub'
55
inputs:
66
python-version:
7-
description: "Version range or exact version of a Python version to use, using SemVer's version range syntax."
8-
default: '3.x'
7+
description: "Version range or exact version of Python to use, using SemVer's version range syntax. Reads from .python-version if unset."
98
python-version-file:
10-
description: "File containing the Python version to use. This overrides 'python-version' if specified. Examples: .python-version"
9+
description: "File containing the Python version to use. Example: .python-version"
1110
cache:
1211
description: 'Used to specify a package manager for caching in the default directory. Supported values: pip, pipenv, poetry.'
1312
required: false

‎package.json

Copy file name to clipboardExpand all lines: package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "setup-python",
3-
"version": "3.1.1",
3+
"version": "4.0.0",
44
"private": true,
55
"description": "Setup python action",
66
"main": "dist/index.js",

‎src/setup-python.ts

Copy file name to clipboardExpand all lines: src/setup-python.ts
+20-12Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,29 @@ async function cacheDependencies(cache: string, pythonVersion: string) {
2424

2525
function resolveVersionInput(): string {
2626
let version = core.getInput('python-version');
27-
const versionFileInput = core.getInput('python-version-file');
27+
const versionFile = core.getInput('python-version-file');
2828

29-
if (versionFileInput) {
30-
const versionFilePath = path.join(
31-
process.env.GITHUB_WORKSPACE!,
32-
versionFileInput
29+
if (version && versionFile) {
30+
core.warning(
31+
'Both python-version and python-version-file inputs are specified, only python-version will be used'
32+
);
33+
}
34+
35+
if (version) {
36+
return version;
37+
}
38+
39+
const versionFilePath = path.join(
40+
process.env.GITHUB_WORKSPACE!,
41+
versionFile || ".python-version"
42+
);
43+
if (!fs.existsSync(versionFilePath)) {
44+
throw new Error(
45+
`The specified python version file at: ${versionFilePath} does not exist`
3346
);
34-
if (!fs.existsSync(versionFilePath)) {
35-
throw new Error(
36-
`The specified node version file at: ${versionFilePath} does not exist`
37-
);
38-
}
39-
version = fs.readFileSync(versionFilePath, 'utf8');
40-
core.info(`Resolved ${versionFileInput} as ${version}`);
4147
}
48+
version = fs.readFileSync(versionFilePath, 'utf8');
49+
core.info(`Resolved ${versionFile} as ${version}`);
4250

4351
return version;
4452
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.