Skip to content

Commit 9f44eb2

Browse files
committed
fix: fix checking of up to date bin min versions
1 parent f85ad55 commit 9f44eb2

File tree

6 files changed

+19
-10
lines changed

6 files changed

+19
-10
lines changed

dist/legacy/setup-cpp.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/setup-cpp.mjs

+1-1
Large diffs are not rendered by default.

dist/modern/setup-cpp.mjs.map

+1-1
Large diffs are not rendered by default.

src/python/python.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,10 @@ import { unique } from "../utils/std/index.js"
2828
import { getVersionDefault, isMinVersion } from "../versions/versions.js"
2929

3030
export async function setupPython(
31-
givenVersion: string,
31+
version: string,
3232
setupDir: string,
3333
arch: string,
3434
): Promise<InstallationInfo & { bin: string }> {
35-
// if a version range specified, use the default version, and later check the range
36-
const version = isMinVersion(givenVersion) ? "" : givenVersion
37-
3835
const installInfo = await findOrSetupPython(version, setupDir, arch)
3936
assert(installInfo.bin !== undefined)
4037
const foundPython = installInfo.bin
@@ -92,7 +89,10 @@ async function setupWheel(foundPython: string) {
9289
}
9390
}
9491

95-
async function findOrSetupPython(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
92+
async function findOrSetupPython(givenVersion: string, setupDir: string, arch: string): Promise<InstallationInfo> {
93+
// if a version range specified, use the default version, and later check the range
94+
const version = isMinVersion(givenVersion) ? "" : givenVersion
95+
9696
let installInfo: InstallationInfo | undefined
9797
let foundPython = await findPython(setupDir)
9898

src/utils/setup/version.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { info } from "ci-log"
33
import { isUrlOnline } from "is-url-online"
44
import semverCoerce from "semver/functions/coerce"
55
import semverCompare from "semver/functions/compare"
6+
import semverSatisfies from "semver/functions/satisfies"
67
import semverValid from "semver/functions/valid"
78

89
/**
@@ -112,7 +113,15 @@ export async function isBinUptoDate(
112113
) {
113114
const givenVersion = await getBinVersion(givenFile, versionRegex)
114115
if (givenVersion !== undefined && targetVersion !== "") {
115-
return semverCompare(givenVersion, targetVersion) !== -1
116+
try {
117+
// if -1, it means the given version is newer than the target version
118+
// this requires the target version to be a valid semver range
119+
return semverCompare(givenVersion, targetVersion) !== -1
120+
} catch {
121+
// check if the given version satisfies the target version
122+
// this works even if the target version is not a valid semver range (e.g. >=1.2.3)
123+
return semverSatisfies(givenVersion, targetVersion)
124+
}
116125
} else {
117126
// assume given version is old
118127
return false

0 commit comments

Comments
 (0)