mirror of https://github.com/aminya/setup-cpp
fix: fix checking of up to date bin min versions
This commit is contained in:
parent
f85ad55d63
commit
9f44eb2c24
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -28,13 +28,10 @@ import { unique } from "../utils/std/index.js"
|
||||||
import { getVersionDefault, isMinVersion } from "../versions/versions.js"
|
import { getVersionDefault, isMinVersion } from "../versions/versions.js"
|
||||||
|
|
||||||
export async function setupPython(
|
export async function setupPython(
|
||||||
givenVersion: string,
|
version: string,
|
||||||
setupDir: string,
|
setupDir: string,
|
||||||
arch: string,
|
arch: string,
|
||||||
): Promise<InstallationInfo & { bin: string }> {
|
): Promise<InstallationInfo & { bin: string }> {
|
||||||
// if a version range specified, use the default version, and later check the range
|
|
||||||
const version = isMinVersion(givenVersion) ? "" : givenVersion
|
|
||||||
|
|
||||||
const installInfo = await findOrSetupPython(version, setupDir, arch)
|
const installInfo = await findOrSetupPython(version, setupDir, arch)
|
||||||
assert(installInfo.bin !== undefined)
|
assert(installInfo.bin !== undefined)
|
||||||
const foundPython = installInfo.bin
|
const foundPython = installInfo.bin
|
||||||
|
@ -92,7 +89,10 @@ async function setupWheel(foundPython: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function findOrSetupPython(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
|
async function findOrSetupPython(givenVersion: string, setupDir: string, arch: string): Promise<InstallationInfo> {
|
||||||
|
// if a version range specified, use the default version, and later check the range
|
||||||
|
const version = isMinVersion(givenVersion) ? "" : givenVersion
|
||||||
|
|
||||||
let installInfo: InstallationInfo | undefined
|
let installInfo: InstallationInfo | undefined
|
||||||
let foundPython = await findPython(setupDir)
|
let foundPython = await findPython(setupDir)
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { info } from "ci-log"
|
||||||
import { isUrlOnline } from "is-url-online"
|
import { isUrlOnline } from "is-url-online"
|
||||||
import semverCoerce from "semver/functions/coerce"
|
import semverCoerce from "semver/functions/coerce"
|
||||||
import semverCompare from "semver/functions/compare"
|
import semverCompare from "semver/functions/compare"
|
||||||
|
import semverSatisfies from "semver/functions/satisfies"
|
||||||
import semverValid from "semver/functions/valid"
|
import semverValid from "semver/functions/valid"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,7 +113,15 @@ export async function isBinUptoDate(
|
||||||
) {
|
) {
|
||||||
const givenVersion = await getBinVersion(givenFile, versionRegex)
|
const givenVersion = await getBinVersion(givenFile, versionRegex)
|
||||||
if (givenVersion !== undefined && targetVersion !== "") {
|
if (givenVersion !== undefined && targetVersion !== "") {
|
||||||
|
try {
|
||||||
|
// if -1, it means the given version is newer than the target version
|
||||||
|
// this requires the target version to be a valid semver range
|
||||||
return semverCompare(givenVersion, targetVersion) !== -1
|
return semverCompare(givenVersion, targetVersion) !== -1
|
||||||
|
} catch {
|
||||||
|
// check if the given version satisfies the target version
|
||||||
|
// this works even if the target version is not a valid semver range (e.g. >=1.2.3)
|
||||||
|
return semverSatisfies(givenVersion, targetVersion)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// assume given version is old
|
// assume given version is old
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in New Issue