mirror of
https://github.com/actions/setup-python.git
synced 2025-04-19 19:33:29 +00:00
Merge 86322ff86a
into 6ed2c67c8a
This commit is contained in:
commit
25173e305b
35
.github/workflows/test-python.yml
vendored
35
.github/workflows/test-python.yml
vendored
@ -284,6 +284,41 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version-file: .tool-versions
|
python-version-file: .tool-versions
|
||||||
|
|
||||||
|
setup-versions-from-mise-toml-file:
|
||||||
|
name: Setup ${{ matrix.python }} ${{ matrix.os }} mise.toml file
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
[
|
||||||
|
macos-latest,
|
||||||
|
windows-latest,
|
||||||
|
ubuntu-20.04,
|
||||||
|
ubuntu-22.04,
|
||||||
|
macos-13,
|
||||||
|
ubuntu-latest
|
||||||
|
]
|
||||||
|
python: [3.13.0, 3.14.0, 3.15.0]
|
||||||
|
exclude:
|
||||||
|
- os: windows-latest
|
||||||
|
python: graalpy-24.1.2
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: build-mise-toml-file ${{ matrix.python }}
|
||||||
|
run: |
|
||||||
|
echo '[tools]
|
||||||
|
python = "${{ matrix.python }}"
|
||||||
|
' > mise.toml
|
||||||
|
|
||||||
|
- name: setup-python using mise.toml ${{ matrix.python }}
|
||||||
|
id: setup-python-mise-toml
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
python-version-file: mise.toml
|
||||||
|
|
||||||
setup-pre-release-version-from-manifest:
|
setup-pre-release-version-from-manifest:
|
||||||
name: Setup 3.14.0-alpha.6 ${{ matrix.os }}
|
name: Setup 3.14.0-alpha.6 ${{ matrix.os }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
@ -216,6 +216,18 @@ describe('Version from file test', () => {
|
|||||||
expect(_fn(toolVersionFilePath)).toEqual(['3.14t-dev']);
|
expect(_fn(toolVersionFilePath)).toEqual(['3.14t-dev']);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it.each([getVersionInputFromTomlFile, getVersionInputFromFile])(
|
||||||
|
'Version from mise.toml',
|
||||||
|
async _fn => {
|
||||||
|
await io.mkdirP(tempDir);
|
||||||
|
const filePath = path.join(tempDir, 'mise.toml');
|
||||||
|
const pythonVersion = '3.8.0';
|
||||||
|
const fileContent = `[tools]\npython = "${pythonVersion}"`;
|
||||||
|
fs.writeFileSync(filePath, fileContent);
|
||||||
|
expect(_fn(filePath)).toEqual([pythonVersion]);
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getNextPageUrl', () => {
|
describe('getNextPageUrl', () => {
|
||||||
|
6
dist/setup/index.js
vendored
6
dist/setup/index.js
vendored
@ -97976,10 +97976,14 @@ function getVersionInputFromTomlFile(versionFile) {
|
|||||||
// standard project metadata (PEP 621)
|
// standard project metadata (PEP 621)
|
||||||
keys = ['project', 'requires-python'];
|
keys = ['project', 'requires-python'];
|
||||||
}
|
}
|
||||||
else {
|
else if ('tool' in pyprojectConfig) {
|
||||||
// python poetry
|
// python poetry
|
||||||
keys = ['tool', 'poetry', 'dependencies', 'python'];
|
keys = ['tool', 'poetry', 'dependencies', 'python'];
|
||||||
}
|
}
|
||||||
|
else if ('tools' in pyprojectConfig) {
|
||||||
|
// mise
|
||||||
|
keys = ['tools', 'python'];
|
||||||
|
}
|
||||||
const versions = [];
|
const versions = [];
|
||||||
const version = extractValue(pyprojectConfig, keys);
|
const version = extractValue(pyprojectConfig, keys);
|
||||||
if (version !== undefined) {
|
if (version !== undefined) {
|
||||||
|
@ -280,7 +280,7 @@ jobs:
|
|||||||
|
|
||||||
`setup-python` action can read Python or PyPy version from a version file. `python-version-file` input is used for specifying the path to the version file. If the file that was supplied to `python-version-file` input doesn't exist, the action will fail with error.
|
`setup-python` action can read Python or PyPy version from a version file. `python-version-file` input is used for specifying the path to the version file. If the file that was supplied to `python-version-file` input doesn't exist, the action will fail with error.
|
||||||
|
|
||||||
>In case both `python-version` and `python-version-file` inputs are supplied, the `python-version-file` input will be ignored due to its lower priority. The .tool-versions file supports version specifications in accordance with asdf standards, adhering to Semantic Versioning ([semver](https://semver.org)).
|
>In case both `python-version` and `python-version-file` inputs are supplied, the `python-version-file` input will be ignored due to its lower priority. The .tool-versions file supports version specifications in accordance with asdf standards, adhering to Semantic Versioning ([semver](https://semver.org)). The `mise.toml` file supports version specifications in accordance with [mise](https://mise.jdx.dev/configuration.html) standards.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
@ -309,6 +309,15 @@ steps:
|
|||||||
- run: python my_script.py
|
- run: python my_script.py
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version-file: 'mise.toml' # Read python version from a file mise.toml
|
||||||
|
- run: python my_script.py
|
||||||
|
```
|
||||||
|
|
||||||
## Check latest version
|
## Check latest version
|
||||||
|
|
||||||
The `check-latest` flag defaults to `false`. Use the default or set `check-latest` to `false` if you prefer stability and if you want to ensure a specific `Python or PyPy` version is always used.
|
The `check-latest` flag defaults to `false`. Use the default or set `check-latest` to `false` if you prefer stability and if you want to ensure a specific `Python or PyPy` version is always used.
|
||||||
|
10
src/utils.ts
10
src/utils.ts
@ -235,15 +235,21 @@ export function getVersionInputFromTomlFile(versionFile: string): string[] {
|
|||||||
pyprojectFile = pyprojectFile.replace(/\r\n/g, '\n');
|
pyprojectFile = pyprojectFile.replace(/\r\n/g, '\n');
|
||||||
|
|
||||||
const pyprojectConfig = toml.parse(pyprojectFile);
|
const pyprojectConfig = toml.parse(pyprojectFile);
|
||||||
let keys = [];
|
let keys: string[] = [];
|
||||||
|
|
||||||
if ('project' in pyprojectConfig) {
|
if ('project' in pyprojectConfig) {
|
||||||
// standard project metadata (PEP 621)
|
// standard project metadata (PEP 621)
|
||||||
keys = ['project', 'requires-python'];
|
keys = ['project', 'requires-python'];
|
||||||
} else {
|
}
|
||||||
|
else if ('tool' in pyprojectConfig) {
|
||||||
// python poetry
|
// python poetry
|
||||||
keys = ['tool', 'poetry', 'dependencies', 'python'];
|
keys = ['tool', 'poetry', 'dependencies', 'python'];
|
||||||
}
|
}
|
||||||
|
else if ('tools' in pyprojectConfig){
|
||||||
|
// mise
|
||||||
|
keys = ['tools', 'python']
|
||||||
|
}
|
||||||
|
|
||||||
const versions = [];
|
const versions = [];
|
||||||
const version = extractValue(pyprojectConfig, keys);
|
const version = extractValue(pyprojectConfig, keys);
|
||||||
if (version !== undefined) {
|
if (version !== undefined) {
|
||||||
|
Loading…
Reference in New Issue
Block a user