@vercel/python 4.0.2 → 4.1.1
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 +129 -14
- package/package.json +9 -5
package/dist/index.js
CHANGED
|
@@ -174,8 +174,8 @@ var require_isexe = __commonJS({
|
|
|
174
174
|
// ../../node_modules/.pnpm/which@1.3.1/node_modules/which/which.js
|
|
175
175
|
var require_which = __commonJS({
|
|
176
176
|
"../../node_modules/.pnpm/which@1.3.1/node_modules/which/which.js"(exports, module2) {
|
|
177
|
-
module2.exports =
|
|
178
|
-
|
|
177
|
+
module2.exports = which2;
|
|
178
|
+
which2.sync = whichSync;
|
|
179
179
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
180
180
|
var path = require("path");
|
|
181
181
|
var COLON = isWindows ? ";" : ":";
|
|
@@ -206,7 +206,7 @@ var require_which = __commonJS({
|
|
|
206
206
|
extExe: pathExtExe
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function which2(cmd, opt, cb) {
|
|
210
210
|
if (typeof opt === "function") {
|
|
211
211
|
cb = opt;
|
|
212
212
|
opt = {};
|
|
@@ -307,7 +307,7 @@ var require_resolveCommand = __commonJS({
|
|
|
307
307
|
"../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module2) {
|
|
308
308
|
"use strict";
|
|
309
309
|
var path = require("path");
|
|
310
|
-
var
|
|
310
|
+
var which2 = require_which();
|
|
311
311
|
var pathKey = require_path_key()();
|
|
312
312
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
313
313
|
const cwd = process.cwd();
|
|
@@ -320,7 +320,7 @@ var require_resolveCommand = __commonJS({
|
|
|
320
320
|
}
|
|
321
321
|
let resolved;
|
|
322
322
|
try {
|
|
323
|
-
resolved =
|
|
323
|
+
resolved = which2.sync(parsed.command, {
|
|
324
324
|
path: (parsed.options.env || process.env)[pathKey],
|
|
325
325
|
pathExt: withoutPathExt ? path.delimiter : void 0
|
|
326
326
|
});
|
|
@@ -2643,6 +2643,94 @@ ${stderr}${stdout}`;
|
|
|
2643
2643
|
}
|
|
2644
2644
|
});
|
|
2645
2645
|
|
|
2646
|
+
// ../../node_modules/.pnpm/which@3.0.0/node_modules/which/lib/index.js
|
|
2647
|
+
var require_lib = __commonJS({
|
|
2648
|
+
"../../node_modules/.pnpm/which@3.0.0/node_modules/which/lib/index.js"(exports, module2) {
|
|
2649
|
+
var isexe = require_isexe();
|
|
2650
|
+
var { join: join2, delimiter, sep, posix } = require("path");
|
|
2651
|
+
var isWindows = process.platform === "win32";
|
|
2652
|
+
var rSlash = new RegExp(`[${posix.sep}${sep === posix.sep ? "" : sep}]`.replace(/(\\)/g, "\\$1"));
|
|
2653
|
+
var rRel = new RegExp(`^\\.${rSlash.source}`);
|
|
2654
|
+
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
2655
|
+
var getPathInfo = (cmd, {
|
|
2656
|
+
path: optPath = process.env.PATH,
|
|
2657
|
+
pathExt: optPathExt = process.env.PATHEXT,
|
|
2658
|
+
delimiter: optDelimiter = delimiter
|
|
2659
|
+
}) => {
|
|
2660
|
+
const pathEnv = cmd.match(rSlash) ? [""] : [
|
|
2661
|
+
// windows always checks the cwd first
|
|
2662
|
+
...isWindows ? [process.cwd()] : [],
|
|
2663
|
+
...(optPath || /* istanbul ignore next: very unusual */
|
|
2664
|
+
"").split(optDelimiter)
|
|
2665
|
+
];
|
|
2666
|
+
if (isWindows) {
|
|
2667
|
+
const pathExtExe = optPathExt || [".EXE", ".CMD", ".BAT", ".COM"].join(optDelimiter);
|
|
2668
|
+
const pathExt = pathExtExe.split(optDelimiter);
|
|
2669
|
+
if (cmd.includes(".") && pathExt[0] !== "") {
|
|
2670
|
+
pathExt.unshift("");
|
|
2671
|
+
}
|
|
2672
|
+
return { pathEnv, pathExt, pathExtExe };
|
|
2673
|
+
}
|
|
2674
|
+
return { pathEnv, pathExt: [""] };
|
|
2675
|
+
};
|
|
2676
|
+
var getPathPart = (raw, cmd) => {
|
|
2677
|
+
const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
|
|
2678
|
+
const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
|
|
2679
|
+
return prefix + join2(pathPart, cmd);
|
|
2680
|
+
};
|
|
2681
|
+
var which2 = async (cmd, opt = {}) => {
|
|
2682
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
2683
|
+
const found = [];
|
|
2684
|
+
for (const envPart of pathEnv) {
|
|
2685
|
+
const p = getPathPart(envPart, cmd);
|
|
2686
|
+
for (const ext of pathExt) {
|
|
2687
|
+
const withExt = p + ext;
|
|
2688
|
+
const is = await isexe(withExt, { pathExt: pathExtExe, ignoreErrors: true });
|
|
2689
|
+
if (is) {
|
|
2690
|
+
if (!opt.all) {
|
|
2691
|
+
return withExt;
|
|
2692
|
+
}
|
|
2693
|
+
found.push(withExt);
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2697
|
+
if (opt.all && found.length) {
|
|
2698
|
+
return found;
|
|
2699
|
+
}
|
|
2700
|
+
if (opt.nothrow) {
|
|
2701
|
+
return null;
|
|
2702
|
+
}
|
|
2703
|
+
throw getNotFoundError(cmd);
|
|
2704
|
+
};
|
|
2705
|
+
var whichSync = (cmd, opt = {}) => {
|
|
2706
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
2707
|
+
const found = [];
|
|
2708
|
+
for (const pathEnvPart of pathEnv) {
|
|
2709
|
+
const p = getPathPart(pathEnvPart, cmd);
|
|
2710
|
+
for (const ext of pathExt) {
|
|
2711
|
+
const withExt = p + ext;
|
|
2712
|
+
const is = isexe.sync(withExt, { pathExt: pathExtExe, ignoreErrors: true });
|
|
2713
|
+
if (is) {
|
|
2714
|
+
if (!opt.all) {
|
|
2715
|
+
return withExt;
|
|
2716
|
+
}
|
|
2717
|
+
found.push(withExt);
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
if (opt.all && found.length) {
|
|
2722
|
+
return found;
|
|
2723
|
+
}
|
|
2724
|
+
if (opt.nothrow) {
|
|
2725
|
+
return null;
|
|
2726
|
+
}
|
|
2727
|
+
throw getNotFoundError(cmd);
|
|
2728
|
+
};
|
|
2729
|
+
module2.exports = which2;
|
|
2730
|
+
which2.sync = whichSync;
|
|
2731
|
+
}
|
|
2732
|
+
});
|
|
2733
|
+
|
|
2646
2734
|
// src/index.ts
|
|
2647
2735
|
var src_exports = {};
|
|
2648
2736
|
__export(src_exports, {
|
|
@@ -2654,10 +2742,10 @@ __export(src_exports, {
|
|
|
2654
2742
|
version: () => version
|
|
2655
2743
|
});
|
|
2656
2744
|
module.exports = __toCommonJS(src_exports);
|
|
2657
|
-
var import_path = require("path");
|
|
2658
|
-
var import_execa2 = __toESM(require_execa());
|
|
2659
2745
|
var import_fs = __toESM(require("fs"));
|
|
2746
|
+
var import_execa2 = __toESM(require_execa());
|
|
2660
2747
|
var import_util = require("util");
|
|
2748
|
+
var import_path = require("path");
|
|
2661
2749
|
var import_build_utils3 = require("@vercel/build-utils");
|
|
2662
2750
|
|
|
2663
2751
|
// src/install.ts
|
|
@@ -2762,7 +2850,20 @@ async function installRequirementsFile({
|
|
|
2762
2850
|
|
|
2763
2851
|
// src/version.ts
|
|
2764
2852
|
var import_build_utils2 = require("@vercel/build-utils");
|
|
2853
|
+
var import_which = __toESM(require_lib());
|
|
2765
2854
|
var allOptions = [
|
|
2855
|
+
{
|
|
2856
|
+
version: "3.11",
|
|
2857
|
+
pipPath: "pip3.11",
|
|
2858
|
+
pythonPath: "python3.11",
|
|
2859
|
+
runtime: "python3.11"
|
|
2860
|
+
},
|
|
2861
|
+
{
|
|
2862
|
+
version: "3.10",
|
|
2863
|
+
pipPath: "pip3.10",
|
|
2864
|
+
pythonPath: "python3.10",
|
|
2865
|
+
runtime: "python3.10"
|
|
2866
|
+
},
|
|
2766
2867
|
{
|
|
2767
2868
|
version: "3.9",
|
|
2768
2869
|
pipPath: "pip3.9",
|
|
@@ -2791,7 +2892,15 @@ function getLatestPythonVersion({
|
|
|
2791
2892
|
if (isDev) {
|
|
2792
2893
|
return getDevPythonVersion();
|
|
2793
2894
|
}
|
|
2794
|
-
|
|
2895
|
+
const selection = allOptions.find(isInstalled2);
|
|
2896
|
+
if (!selection) {
|
|
2897
|
+
throw new import_build_utils2.NowBuildError({
|
|
2898
|
+
code: "PYTHON_NOT_FOUND",
|
|
2899
|
+
link: "http://vercel.link/python-version",
|
|
2900
|
+
message: `Unable to find any supported Python versions.`
|
|
2901
|
+
});
|
|
2902
|
+
}
|
|
2903
|
+
return selection;
|
|
2795
2904
|
}
|
|
2796
2905
|
function getSupportedPythonVersion({
|
|
2797
2906
|
isDev,
|
|
@@ -2802,7 +2911,9 @@ function getSupportedPythonVersion({
|
|
|
2802
2911
|
}
|
|
2803
2912
|
let selection = getLatestPythonVersion({ isDev: false });
|
|
2804
2913
|
if (typeof pipLockPythonVersion === "string") {
|
|
2805
|
-
const found = allOptions.find(
|
|
2914
|
+
const found = allOptions.find(
|
|
2915
|
+
(o) => o.version === pipLockPythonVersion && isInstalled2(o)
|
|
2916
|
+
);
|
|
2806
2917
|
if (found) {
|
|
2807
2918
|
selection = found;
|
|
2808
2919
|
} else {
|
|
@@ -2830,6 +2941,9 @@ function isDiscontinued({ discontinueDate }) {
|
|
|
2830
2941
|
const today = Date.now();
|
|
2831
2942
|
return discontinueDate !== void 0 && discontinueDate.getTime() <= today;
|
|
2832
2943
|
}
|
|
2944
|
+
function isInstalled2({ pipPath, pythonPath }) {
|
|
2945
|
+
return Boolean(import_which.default.sync(pipPath, { nothrow: true })) && Boolean(import_which.default.sync(pythonPath, { nothrow: true }));
|
|
2946
|
+
}
|
|
2833
2947
|
|
|
2834
2948
|
// src/index.ts
|
|
2835
2949
|
var readFile = (0, import_util.promisify)(import_fs.default.readFile);
|
|
@@ -2961,19 +3075,20 @@ var build = async ({
|
|
|
2961
3075
|
const entrypointWithSuffix = `${entrypoint}${suffix}`;
|
|
2962
3076
|
(0, import_build_utils3.debug)("Entrypoint with suffix is", entrypointWithSuffix);
|
|
2963
3077
|
const handlerPyContents = originalHandlerPyContents.replace(/__VC_HANDLER_MODULE_NAME/g, moduleName).replace(/__VC_HANDLER_ENTRYPOINT/g, entrypointWithSuffix);
|
|
2964
|
-
const handlerPyFilename = "vc__handler__python";
|
|
2965
|
-
await writeFile((0, import_path.join)(workPath, `${handlerPyFilename}.py`), handlerPyContents);
|
|
2966
3078
|
const globOptions = {
|
|
2967
3079
|
cwd: workPath,
|
|
2968
3080
|
ignore: config && typeof config.excludeFiles === "string" ? config.excludeFiles : "node_modules/**"
|
|
2969
3081
|
};
|
|
2970
|
-
const
|
|
2971
|
-
|
|
3082
|
+
const files = await (0, import_build_utils3.glob)("**", globOptions);
|
|
3083
|
+
const handlerPyFilename = "vc__handler__python";
|
|
3084
|
+
files[`${handlerPyFilename}.py`] = new import_build_utils3.FileBlob({ data: handlerPyContents });
|
|
3085
|
+
const output = new import_build_utils3.Lambda({
|
|
3086
|
+
files,
|
|
2972
3087
|
handler: `${handlerPyFilename}.vc_handler`,
|
|
2973
3088
|
runtime: pythonVersion.runtime,
|
|
2974
3089
|
environment: {}
|
|
2975
3090
|
});
|
|
2976
|
-
return { output
|
|
3091
|
+
return { output };
|
|
2977
3092
|
};
|
|
2978
3093
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2979
3094
|
0 && (module.exports = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/python",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
|
|
@@ -15,17 +15,21 @@
|
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@types/execa": "^0.9.0",
|
|
18
|
+
"@types/fs-extra": "11.0.2",
|
|
18
19
|
"@types/jest": "27.4.1",
|
|
19
20
|
"@types/node": "14.18.33",
|
|
20
|
-
"@
|
|
21
|
-
"@vercel/
|
|
21
|
+
"@types/which": "3.0.0",
|
|
22
|
+
"@vercel/build-utils": "7.5.1",
|
|
22
23
|
"execa": "^1.0.0",
|
|
23
|
-
"
|
|
24
|
+
"fs-extra": "11.1.1",
|
|
25
|
+
"jest-junit": "16.0.0",
|
|
26
|
+
"which": "3.0.0"
|
|
24
27
|
},
|
|
25
28
|
"scripts": {
|
|
26
29
|
"build": "node ../../utils/build-builder.mjs",
|
|
27
30
|
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail",
|
|
28
31
|
"test-unit": "pnpm test test/unit.test.ts",
|
|
29
|
-
"test-e2e": "pnpm test test/integration-*"
|
|
32
|
+
"test-e2e": "pnpm test test/integration-*",
|
|
33
|
+
"type-check": "tsc --noEmit"
|
|
30
34
|
}
|
|
31
35
|
}
|