mirror of
https://github.com/actions/setup-python.git
synced 2025-04-21 14:28:42 +00:00
Get rid of stable boolean input
This commit is contained in:
parent
d025544791
commit
d6f2ec53d6
8 changed files with 48 additions and 30 deletions
29
.github/workflows/test.yml
vendored
29
.github/workflows/test.yml
vendored
|
@ -61,3 +61,32 @@ jobs:
|
|||
|
||||
- name: Run simple code
|
||||
run: python -c 'import math; print(math.factorial(5))'
|
||||
|
||||
setup-pre-release-version-from-manifest:
|
||||
name: Setup 3.9.0-beta.4 ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-16.04, ubuntu-18.04]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: setup-python 3.9.0-beta.4
|
||||
uses: ./
|
||||
with:
|
||||
python-version: '3.9.0-beta.4'
|
||||
|
||||
- name: Validate version
|
||||
run: |
|
||||
$pythonVersion = (python --version)
|
||||
if ("Python ${{ matrix.python }}" -ne "$pythonVersion"){
|
||||
Write-Host "The current version is $pythonVersion; expected version is ${{ matrix.python }}"
|
||||
exit 1
|
||||
}
|
||||
$pythonVersion
|
||||
shell: pwsh
|
||||
|
||||
- name: Run simple code
|
||||
run: python -c 'import math; print(math.factorial(5))'
|
||||
|
|
|
@ -99,7 +99,6 @@ steps:
|
|||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.9.0-beta.4'
|
||||
stable: false # optional true or false. Defaults to true if not specified
|
||||
- run: python my_script.py
|
||||
```
|
||||
|
||||
|
@ -110,7 +109,6 @@ steps:
|
|||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.9.0-alpha - 3.9.0' # SemVer's version range syntax
|
||||
stable: false # optional true or false. Defaults to true if not specified
|
||||
- run: python my_script.py
|
||||
```
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ describe('Finder tests', () => {
|
|||
await io.mkdirP(pythonDir);
|
||||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||
await finder.findPythonVersion('3.x', 'x64', true);
|
||||
await finder.findPythonVersion('3.x', 'x64');
|
||||
});
|
||||
|
||||
it('Finds stable Python version if it is not installed, but exists in the manifest', async () => {
|
||||
|
@ -52,7 +52,7 @@ describe('Finder tests', () => {
|
|||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||
});
|
||||
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||
await finder.findPythonVersion('1.2.3', 'x64', true);
|
||||
await finder.findPythonVersion('1.2.3', 'x64');
|
||||
});
|
||||
|
||||
it('Finds pre-release Python version in the manifest', async () => {
|
||||
|
@ -74,14 +74,14 @@ describe('Finder tests', () => {
|
|||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||
});
|
||||
// This will throw if it doesn't find it in the manifest (because no such version exists)
|
||||
await finder.findPythonVersion('1.2.3-beta.2', 'x64', false);
|
||||
await finder.findPythonVersion('1.2.3-beta.2', 'x64');
|
||||
});
|
||||
|
||||
it('Errors if Python is not installed', async () => {
|
||||
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||
let thrown = false;
|
||||
try {
|
||||
await finder.findPythonVersion('3.300000', 'x64', true);
|
||||
await finder.findPythonVersion('3.300000', 'x64');
|
||||
} catch {
|
||||
thrown = true;
|
||||
}
|
||||
|
@ -93,6 +93,6 @@ describe('Finder tests', () => {
|
|||
await io.mkdirP(pythonDir);
|
||||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||
// This will throw if it doesn't find it in the cache (because no such version exists)
|
||||
await finder.findPythonVersion('pypy2', 'x64', true);
|
||||
await finder.findPythonVersion('pypy2', 'x64');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -8,9 +8,6 @@ inputs:
|
|||
default: '3.x'
|
||||
architecture:
|
||||
description: 'The target architecture (x86, x64) of the Python interpreter.'
|
||||
stable:
|
||||
description: 'Whether to download only stable versions'
|
||||
default: 'true'
|
||||
token:
|
||||
description: Used to pull python distributions from actions/python-versions. Since there's a default, this is typically not supplied by the user.
|
||||
default: ${{ github.token }}
|
||||
|
|
15
dist/index.js
vendored
15
dist/index.js
vendored
|
@ -1143,10 +1143,10 @@ const MANIFEST_REPO_NAME = 'python-versions';
|
|||
const MANIFEST_REPO_BRANCH = 'main';
|
||||
exports.MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/${MANIFEST_REPO_BRANCH}/versions-manifest.json`;
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
function findReleaseFromManifest(semanticVersionSpec, architecture, stable) {
|
||||
function findReleaseFromManifest(semanticVersionSpec, architecture) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const manifest = yield tc.getManifestFromRepo(MANIFEST_REPO_OWNER, MANIFEST_REPO_NAME, AUTH, MANIFEST_REPO_BRANCH);
|
||||
return yield tc.findFromManifest(semanticVersionSpec, stable, manifest, architecture);
|
||||
return yield tc.findFromManifest(semanticVersionSpec, false, manifest, architecture);
|
||||
});
|
||||
}
|
||||
exports.findReleaseFromManifest = findReleaseFromManifest;
|
||||
|
@ -1627,8 +1627,7 @@ function run() {
|
|||
let version = core.getInput('python-version');
|
||||
if (version) {
|
||||
const arch = core.getInput('architecture') || os.arch();
|
||||
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
|
||||
const installed = yield finder.findPythonVersion(version, arch, stable);
|
||||
const installed = yield finder.findPythonVersion(version, arch);
|
||||
core.info(`Successfully setup ${installed.impl} (${installed.version})`);
|
||||
}
|
||||
const matchersPath = path.join(__dirname, '..', '.github');
|
||||
|
@ -2308,7 +2307,7 @@ function usePyPy(majorVersion, architecture) {
|
|||
core.setOutput('python-version', impl);
|
||||
return { impl: impl, version: versionFromPath(installDir) };
|
||||
}
|
||||
function useCpythonVersion(version, architecture, stable) {
|
||||
function useCpythonVersion(version, architecture) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const desugaredVersionSpec = desugarDevVersion(version);
|
||||
const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
|
||||
|
@ -2316,7 +2315,7 @@ function useCpythonVersion(version, architecture, stable) {
|
|||
let installDir = tc.find('Python', semanticVersionSpec, architecture);
|
||||
if (!installDir) {
|
||||
core.info(`Version ${semanticVersionSpec} was not found in the local cache`);
|
||||
const foundRelease = yield installer.findReleaseFromManifest(semanticVersionSpec, architecture, stable);
|
||||
const foundRelease = yield installer.findReleaseFromManifest(semanticVersionSpec, architecture);
|
||||
if (foundRelease && foundRelease.files && foundRelease.files.length > 0) {
|
||||
core.info(`Version ${semanticVersionSpec} is available for downloading`);
|
||||
yield installer.installCpythonFromRelease(foundRelease);
|
||||
|
@ -2374,7 +2373,7 @@ function pythonVersionToSemantic(versionSpec) {
|
|||
return versionSpec.replace(prereleaseVersion, '$1-$2');
|
||||
}
|
||||
exports.pythonVersionToSemantic = pythonVersionToSemantic;
|
||||
function findPythonVersion(version, architecture, stable) {
|
||||
function findPythonVersion(version, architecture) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
switch (version.toUpperCase()) {
|
||||
case 'PYPY2':
|
||||
|
@ -2382,7 +2381,7 @@ function findPythonVersion(version, architecture, stable) {
|
|||
case 'PYPY3':
|
||||
return usePyPy(3, architecture);
|
||||
default:
|
||||
return yield useCpythonVersion(version, architecture, stable);
|
||||
return yield useCpythonVersion(version, architecture);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -71,8 +71,7 @@ function usePyPy(majorVersion: 2 | 3, architecture: string): InstalledVersion {
|
|||
|
||||
async function useCpythonVersion(
|
||||
version: string,
|
||||
architecture: string,
|
||||
stable: boolean
|
||||
architecture: string
|
||||
): Promise<InstalledVersion> {
|
||||
const desugaredVersionSpec = desugarDevVersion(version);
|
||||
const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
|
||||
|
@ -89,8 +88,7 @@ async function useCpythonVersion(
|
|||
);
|
||||
const foundRelease = await installer.findReleaseFromManifest(
|
||||
semanticVersionSpec,
|
||||
architecture,
|
||||
stable
|
||||
architecture
|
||||
);
|
||||
|
||||
if (foundRelease && foundRelease.files && foundRelease.files.length > 0) {
|
||||
|
@ -173,8 +171,7 @@ export function pythonVersionToSemantic(versionSpec: string) {
|
|||
|
||||
export async function findPythonVersion(
|
||||
version: string,
|
||||
architecture: string,
|
||||
stable: boolean
|
||||
architecture: string
|
||||
): Promise<InstalledVersion> {
|
||||
switch (version.toUpperCase()) {
|
||||
case 'PYPY2':
|
||||
|
@ -182,6 +179,6 @@ export async function findPythonVersion(
|
|||
case 'PYPY3':
|
||||
return usePyPy(3, architecture);
|
||||
default:
|
||||
return await useCpythonVersion(version, architecture, stable);
|
||||
return await useCpythonVersion(version, architecture);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,7 @@ const IS_WINDOWS = process.platform === 'win32';
|
|||
|
||||
export async function findReleaseFromManifest(
|
||||
semanticVersionSpec: string,
|
||||
architecture: string,
|
||||
stable: boolean
|
||||
architecture: string
|
||||
): Promise<tc.IToolRelease | undefined> {
|
||||
const manifest: tc.IToolRelease[] = await tc.getManifestFromRepo(
|
||||
MANIFEST_REPO_OWNER,
|
||||
|
@ -26,7 +25,7 @@ export async function findReleaseFromManifest(
|
|||
);
|
||||
return await tc.findFromManifest(
|
||||
semanticVersionSpec,
|
||||
stable,
|
||||
false,
|
||||
manifest,
|
||||
architecture
|
||||
);
|
||||
|
|
|
@ -8,8 +8,7 @@ async function run() {
|
|||
let version = core.getInput('python-version');
|
||||
if (version) {
|
||||
const arch: string = core.getInput('architecture') || os.arch();
|
||||
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
|
||||
const installed = await finder.findPythonVersion(version, arch, stable);
|
||||
const installed = await finder.findPythonVersion(version, arch);
|
||||
core.info(`Successfully setup ${installed.impl} (${installed.version})`);
|
||||
}
|
||||
const matchersPath = path.join(__dirname, '..', '.github');
|
||||
|
|
Loading…
Add table
Reference in a new issue