8000 dev7 · akv-platform/setup-python@393d1dd · GitHub
[go: up one dir, main page]

Skip to content

Commit 393d1dd

Browse files
committed
dev7
1 parent 21915df commit 393d1dd

File tree

2 files changed

+142
-3
lines changed

2 files changed

+142
-3
lines changed

dist/setup/index.js

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64393,7 +64393,7 @@ exports.findAssetForMacOrLinux = findAssetForMacOrLinux;
6439364393
/***/ }),
6439464394

6439564395
/***/ 2745:
64396-
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
64396+
/***/ (function(module, exports, __nccwpck_require__) {
6439764397

6439864398
"use strict";
6439964399

@@ -64438,10 +64438,56 @@ const MANIFEST_REPO_OWNER = 'actions';
6443864438
const MANIFEST_REPO_NAME = 'python-versions';
6443964439
const MANIFEST_REPO_BRANCH = 'main';
6444064440
exports.MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/${MANIFEST_REPO_BRANCH}/versions-manifest.json`;
64441+
const os = __nccwpck_require__(2037);
64442+
const semver = __importStar(__nccwpck_require__(1383));
64443+
function _findMatch(versionSpec, stable, candidates, archFilter) {
64444+
return __awaiter(this, void 0, void 0, function* () {
64445+
const platFilter = os.platform();
64446+
let result;
64447+
let match;
64448+
let file;
64449+
for (const candidate of candidates) {
64450+
const version = candidate.version;
64451+
core.debug(`check ${version} satisfies ${versionSpec}`);
64452+
if (semver.satisfies(version, versionSpec) &&
64453+
(!stable || candidate.stable === stable)) {
64454+
file = candidate.files.find(item => {
64455+
core.debug(`item.arch:${item.arch}===archFilter:${archFilter} && item.platform:${item.platform}===platFilter:${platFilter}`);
64456+
let chk = item.arch === archFilter && item.platform === platFilter;
64457+
core.debug(`chk = ${chk} item.platform_version = ${item.platform_version}`);
64458+
if (chk && item.platform_version) {
64459+
const osVersion = module.exports._getOsVersion();
64460+
core.debug(`osVersion = ${osVersion} item.platform_version = ${item.platform_version}`);
64461+
if (osVersion === item.platform_version) {
64462+
chk = true;
64463+
}
64464+
else {
64465+
chk = semver.satisfies(osVersion, item.platform_version);
64466+
}
64467+
core.debug(`chk2 = ${chk}`);
64468+
}
64469+
return chk;
64470+
});
64471+
if (file) {
64472+
core.debug(`matched ${candidate.version}`);
64473+
match = candidate;
64474+
break;
64475+
}
64476+
}
64477+
}
64478+
if (match && file) {
64479+
// clone since we're mutating the file list to be only the file that matches
64480+
result = Object.assign({}, match);
64481+
result.files = [file];
64482+
}
64483+
return result;
64484+
});
64485+
}
6444164486
function findReleaseFromManifest(semanticVersionSpec, architecture) {
6444264487
return __awaiter(this, void 0, void 0, function* () {
6444364488
const manifest = yield tc.getManifestFromRepo(MANIFEST_REPO_OWNER, MANIFEST_REPO_NAME, AUTH, MANIFEST_REPO_BRANCH);
64444-
core.debug(`semanticVersionSpec=${semanticVersionSpec} manifest=${JSON.stringify(manifest)} architecture=${architecture}`);
64489+
// core.debug(`semanticVersionSpec=${semanticVersionSpec} manifest=${JSON.stringify(manifest)} architecture=${architecture}`)
64490+
yield _findMatch(semanticVersionSpec, false, manifest, architecture);
6444564491
return yield tc.findFromManifest(semanticVersionSpec, false, manifest, architecture);
6444664492
});
6444764493
}

src/install-python.ts

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,93 @@ const MANIFEST_REPO_OWNER = 'actions';
1111
const MANIFEST_REPO_NAME = 'python-versions';
1212
const MANIFEST_REPO_BRANCH = 'main';
1313
export const MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/${MANIFEST_REPO_BRANCH}/versions-manifest.json`;
14+
import os = require('os')
15+
import * as semver from 'semver'
16+
17+
interface IToolReleaseFile {
18+
filename: string
19+
// 'aix', 'darwin', 'freebsd', 'linux', 'openbsd',
20+
// 'sunos', and 'win32'
21+
// platform_version is an optional semver filter
22+
// TODO: do we need distribution (e.g. ubuntu).
23+
// not adding yet but might need someday.
24+
// right now, 16.04 and 18.04 work
25+
platform: string
26+
platform_version?: string
27+
28+
// 'arm', 'arm64', 'ia32', 'mips', 'mipsel',
29+
// 'ppc', 'ppc64', 's390', 's390x',
30+
// 'x32', and 'x64'.
31+
arch: string
32+
33+
download_url: string
34+
}
35+
36+
interface IToolRelease {
37+
version: string
38+
stable: boolean
39+
release_url: string
40+
files: IToolReleaseFile[]
41+
}
42+
43+
async function _findMatch(
44+
versionSpec: string,
45+
stable: boolean,
46+
candidates: IToolRelease[],
47+
archFilter: string
48+
): Promise<IToolRelease | undefined> {
49+
const platFilter = os.platform()
50+
51+
let result: IToolRelease | undefined
52+
let match: IToolRelease | undefined
53+
54+
let file: IToolReleaseFile | undefined
55+
for (const candidate of candidates) {
56+
const version = candidate.version
57+
58+
core.debug(`check ${version} satisfies ${versionSpec}`)
59+
if (
60+
semver.satisfies(version, versionSpec) &&
61+
(!stable || candidate.stable === stable)
62+
) {
63+
file = candidate.files.find(item => {
64+
core.debug(
65+
`item.arch:${item.arch}===archFilter:${archFilter} && item.platform:${item.platform}===platFilter:${platFilter}`
66+
)
67+
68+
let chk = item.arch === archFilter && item.platform === platFilter
69+
core.debug(`chk = ${chk} item.platform_version = ${item.platform_version}`)
70+
if (chk && item.platform_version) {
71+
const osVersion = module.exports._getOsVersion()
72+
core.debug(`osVersion = ${osVersion} item.platform_version = ${item.platform_version}`)
73+
74+
if (osVersion === item.platform_version) {
75+
chk = true
76+
} else {
77+
chk = semver.satisfies(osVersion, item.platform_version)
78+
}
79+
core.debug(`chk2 = ${chk}`)
80+
}
81+
82+
return chk
83+
})
84+
85+
if (file) {
86+
core.debug(`matched ${candidate.version}`)
87+
match = candidate
88+
break
89+
}
90+
}
91+
}
92+
93+
if (match && file) {
94+
// clone since we're mutating the file list to be only the file that matches
95+
result = Object.assign({}, match)
96+
result.files = [file]
97+
}
98+
99+
return result
100+
}
14101

15102
export async function findReleaseFromManifest(
16103
semanticVersionSpec: string,
@@ -22,7 +109,13 @@ export async function findReleaseFromManifest(
22109
AUTH,
23110
MANIFEST_REPO_BRANCH
24111
);
25-
core.debug(`semanticVersionSpec=${semanticVersionSpec} manifest=${JSON.stringify(manifest)} architecture=${architecture}`)
112+
// core.debug(`semanticVersionSpec=${semanticVersionSpec} manifest=${JSON.stringify(manifest)} architecture=${architecture}`)
113+
await _findMatch(
114+
semanticVersionSpec,
115+
false,
116+
manifest,
117+
architecture
118+
);
26119
return await tc.findFromManifest(
27120
semanticVersionSpec,
28121
false,

0 commit comments

Comments
 (0)
0