@vercel/python 6.0.4 → 6.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +95 -36
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -989,10 +989,10 @@ var require_semver = __commonJS({
|
|
|
989
989
|
var rangeTmp;
|
|
990
990
|
if (this.operator === "") {
|
|
991
991
|
rangeTmp = new Range(comp.value, options);
|
|
992
|
-
return
|
|
992
|
+
return satisfies2(this.value, rangeTmp, options);
|
|
993
993
|
} else if (comp.operator === "") {
|
|
994
994
|
rangeTmp = new Range(this.value, options);
|
|
995
|
-
return
|
|
995
|
+
return satisfies2(comp.semver, rangeTmp, options);
|
|
996
996
|
}
|
|
997
997
|
var sameDirectionIncreasing = (this.operator === ">=" || this.operator === ">") && (comp.operator === ">=" || comp.operator === ">");
|
|
998
998
|
var sameDirectionDecreasing = (this.operator === "<=" || this.operator === "<") && (comp.operator === "<=" || comp.operator === "<");
|
|
@@ -1301,8 +1301,8 @@ var require_semver = __commonJS({
|
|
|
1301
1301
|
}
|
|
1302
1302
|
return true;
|
|
1303
1303
|
}
|
|
1304
|
-
exports.satisfies =
|
|
1305
|
-
function
|
|
1304
|
+
exports.satisfies = satisfies2;
|
|
1305
|
+
function satisfies2(version2, range, options) {
|
|
1306
1306
|
try {
|
|
1307
1307
|
range = new Range(range, options);
|
|
1308
1308
|
} catch (er) {
|
|
@@ -1430,7 +1430,7 @@ var require_semver = __commonJS({
|
|
|
1430
1430
|
default:
|
|
1431
1431
|
throw new TypeError('Must provide a hilo val of "<" or ">"');
|
|
1432
1432
|
}
|
|
1433
|
-
if (
|
|
1433
|
+
if (satisfies2(version2, range, options)) {
|
|
1434
1434
|
return false;
|
|
1435
1435
|
}
|
|
1436
1436
|
for (var i2 = 0; i2 < range.set.length; ++i2) {
|
|
@@ -3133,6 +3133,81 @@ function getLatestPythonVersion({
|
|
|
3133
3133
|
}
|
|
3134
3134
|
return selection;
|
|
3135
3135
|
}
|
|
3136
|
+
function parseVersionTuple(input) {
|
|
3137
|
+
const cleaned = input.trim().replace(/\s+/g, "");
|
|
3138
|
+
const m = cleaned.match(/^(\d+)(?:\.(\d+))?/);
|
|
3139
|
+
if (!m)
|
|
3140
|
+
return null;
|
|
3141
|
+
const major = Number(m[1]);
|
|
3142
|
+
const minor = m[2] !== void 0 ? Number(m[2]) : 0;
|
|
3143
|
+
if (Number.isNaN(major) || Number.isNaN(minor))
|
|
3144
|
+
return null;
|
|
3145
|
+
return [major, minor];
|
|
3146
|
+
}
|
|
3147
|
+
function compareTuples(a, b) {
|
|
3148
|
+
if (a[0] !== b[0])
|
|
3149
|
+
return a[0] - b[0];
|
|
3150
|
+
return a[1] - b[1];
|
|
3151
|
+
}
|
|
3152
|
+
function parseSpecifier(spec) {
|
|
3153
|
+
const s = spec.trim();
|
|
3154
|
+
const m = s.match(/^(<=|>=|==|!=|~=|<|>)\s*([0-9]+(?:\.[0-9]+)?)(?:\.\*)?$/) || // Bare version like "3.11" -> implied ==
|
|
3155
|
+
s.match(/^()([0-9]+(?:\.[0-9]+)?)(?:\.\*)?$/);
|
|
3156
|
+
if (!m)
|
|
3157
|
+
return null;
|
|
3158
|
+
const op = m[1] || "==";
|
|
3159
|
+
const vt = parseVersionTuple(m[2]);
|
|
3160
|
+
if (!vt)
|
|
3161
|
+
return null;
|
|
3162
|
+
return { op, ver: vt };
|
|
3163
|
+
}
|
|
3164
|
+
function satisfies(candidate, spec) {
|
|
3165
|
+
const cmp = compareTuples(candidate, spec.ver);
|
|
3166
|
+
switch (spec.op) {
|
|
3167
|
+
case "==":
|
|
3168
|
+
return cmp === 0;
|
|
3169
|
+
case "!=":
|
|
3170
|
+
return cmp !== 0;
|
|
3171
|
+
case "<":
|
|
3172
|
+
return cmp < 0;
|
|
3173
|
+
case "<=":
|
|
3174
|
+
return cmp <= 0;
|
|
3175
|
+
case ">":
|
|
3176
|
+
return cmp > 0;
|
|
3177
|
+
case ">=":
|
|
3178
|
+
return cmp >= 0;
|
|
3179
|
+
case "~=": {
|
|
3180
|
+
const lowerOk = cmp >= 0;
|
|
3181
|
+
const upper = [spec.ver[0], spec.ver[1] + 1];
|
|
3182
|
+
return lowerOk && compareTuples(candidate, upper) < 0;
|
|
3183
|
+
}
|
|
3184
|
+
default:
|
|
3185
|
+
return false;
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
function selectFromRequiresPython(expr) {
|
|
3189
|
+
const raw = expr.trim();
|
|
3190
|
+
if (!raw)
|
|
3191
|
+
return void 0;
|
|
3192
|
+
const parts = raw.split(",").map((p) => p.trim()).filter(Boolean);
|
|
3193
|
+
const specifiers = [];
|
|
3194
|
+
for (const p of parts) {
|
|
3195
|
+
const sp = parseSpecifier(p);
|
|
3196
|
+
if (sp)
|
|
3197
|
+
specifiers.push(sp);
|
|
3198
|
+
}
|
|
3199
|
+
if (specifiers.length === 0) {
|
|
3200
|
+
return allOptions.find((o) => o.version === raw);
|
|
3201
|
+
}
|
|
3202
|
+
const matches = allOptions.filter((opt) => {
|
|
3203
|
+
const vt = parseVersionTuple(opt.version);
|
|
3204
|
+
return specifiers.every((sp) => satisfies(vt, sp));
|
|
3205
|
+
});
|
|
3206
|
+
if (matches.length === 0)
|
|
3207
|
+
return void 0;
|
|
3208
|
+
const installedMatch = matches.find(isInstalled2);
|
|
3209
|
+
return installedMatch ?? matches[0];
|
|
3210
|
+
}
|
|
3136
3211
|
function getSupportedPythonVersion({
|
|
3137
3212
|
isDev,
|
|
3138
3213
|
declaredPythonVersion
|
|
@@ -3143,7 +3218,12 @@ function getSupportedPythonVersion({
|
|
|
3143
3218
|
let selection = getLatestPythonVersion({ isDev: false });
|
|
3144
3219
|
if (declaredPythonVersion) {
|
|
3145
3220
|
const { version: version2, source } = declaredPythonVersion;
|
|
3146
|
-
|
|
3221
|
+
let requested;
|
|
3222
|
+
if (source === "pyproject.toml") {
|
|
3223
|
+
requested = selectFromRequiresPython(version2);
|
|
3224
|
+
} else {
|
|
3225
|
+
requested = allOptions.find((o) => o.version === version2);
|
|
3226
|
+
}
|
|
3147
3227
|
if (requested) {
|
|
3148
3228
|
if (isDiscontinued(requested)) {
|
|
3149
3229
|
throw new import_build_utils2.NowBuildError({
|
|
@@ -3334,7 +3414,6 @@ async function detectPythonEntrypoint(framework, workPath, configuredEntrypoint)
|
|
|
3334
3414
|
// src/utils.ts
|
|
3335
3415
|
var import_fs3 = __toESM(require("fs"));
|
|
3336
3416
|
var import_path3 = require("path");
|
|
3337
|
-
var import_execa2 = __toESM(require_execa());
|
|
3338
3417
|
var import_build_utils5 = require("@vercel/build-utils");
|
|
3339
3418
|
var isInVirtualEnv = () => {
|
|
3340
3419
|
return process.env.VIRTUAL_ENV;
|
|
@@ -3374,27 +3453,12 @@ async function runPyprojectScript(workPath, scriptNames, env) {
|
|
|
3374
3453
|
return false;
|
|
3375
3454
|
const systemPython = process.platform === "win32" ? "python" : "python3";
|
|
3376
3455
|
const finalEnv = { ...process.env, ...env };
|
|
3377
|
-
|
|
3378
|
-
const uvPath = await getUvBinaryOrInstall(pythonCmd);
|
|
3456
|
+
useVirtualEnv(workPath, finalEnv, systemPython);
|
|
3379
3457
|
const scriptCommand = scripts[scriptToRun];
|
|
3380
3458
|
if (typeof scriptCommand === "string" && scriptCommand.trim()) {
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
if (/^\s*uv(\s|$)/i.test(scriptCommand)) {
|
|
3384
|
-
console.log(`Executing: ${scriptCommand}`);
|
|
3385
|
-
await (0, import_build_utils5.execCommand)(scriptCommand, {
|
|
3386
|
-
cwd: workPath,
|
|
3387
|
-
env: finalEnv
|
|
3388
|
-
});
|
|
3389
|
-
return true;
|
|
3390
|
-
}
|
|
3391
|
-
const args = process.platform === "win32" ? ["run", "cmd", "/d", "/s", "/c", scriptCommand] : ["run", "sh", "-lc", scriptCommand];
|
|
3392
|
-
console.log(
|
|
3393
|
-
`Executing: ${uvPath} ${args.map((a) => /\s/.test(a) ? `"${a.replace(/"/g, '\\"')}"` : a).join(" ")}`
|
|
3394
|
-
);
|
|
3395
|
-
await (0, import_execa2.default)(uvPath, args, {
|
|
3459
|
+
console.log(`Executing: ${scriptCommand}`);
|
|
3460
|
+
await (0, import_build_utils5.execCommand)(scriptCommand, {
|
|
3396
3461
|
cwd: workPath,
|
|
3397
|
-
stdio: "inherit",
|
|
3398
3462
|
env: finalEnv
|
|
3399
3463
|
});
|
|
3400
3464
|
return true;
|
|
@@ -3920,17 +3984,12 @@ var build = async ({
|
|
|
3920
3984
|
} catch (err) {
|
|
3921
3985
|
(0, import_build_utils7.debug)("Failed to parse pyproject.toml", err);
|
|
3922
3986
|
}
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
);
|
|
3930
|
-
} else if (requiresPython) {
|
|
3931
|
-
(0, import_build_utils7.debug)(
|
|
3932
|
-
`Could not parse Python version from pyproject.toml requires-python: "${requiresPython}"`
|
|
3933
|
-
);
|
|
3987
|
+
if (typeof requiresPython === "string" && requiresPython.trim()) {
|
|
3988
|
+
declaredPythonVersion = {
|
|
3989
|
+
version: requiresPython.trim(),
|
|
3990
|
+
source: "pyproject.toml"
|
|
3991
|
+
};
|
|
3992
|
+
(0, import_build_utils7.debug)(`Found requires-python "${requiresPython}" in pyproject.toml`);
|
|
3934
3993
|
}
|
|
3935
3994
|
} else if (pipfileLockDir) {
|
|
3936
3995
|
let lock = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/python",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.6",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@types/jest": "27.4.1",
|
|
22
22
|
"@types/node": "14.18.33",
|
|
23
23
|
"@types/which": "3.0.0",
|
|
24
|
-
"@vercel/build-utils": "13.0
|
|
24
|
+
"@vercel/build-utils": "13.1.0",
|
|
25
25
|
"cross-env": "7.0.3",
|
|
26
26
|
"execa": "^1.0.0",
|
|
27
27
|
"fs-extra": "11.1.1",
|