@vercel/python 6.22.0 → 6.22.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 +13 -69
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2862,7 +2862,6 @@ __export(src_exports, {
|
|
|
2862
2862
|
downloadFilesInWorkPath: () => downloadFilesInWorkPath,
|
|
2863
2863
|
installRequirement: () => installRequirement,
|
|
2864
2864
|
installRequirementsFile: () => installRequirementsFile,
|
|
2865
|
-
prepareCache: () => prepareCache,
|
|
2866
2865
|
runFrameworkHook: () => runFrameworkHook,
|
|
2867
2866
|
shouldServe: () => shouldServe,
|
|
2868
2867
|
startDevServer: () => startDevServer,
|
|
@@ -2904,19 +2903,14 @@ var import_build_utils = require("@vercel/build-utils");
|
|
|
2904
2903
|
var UV_VERSION = "0.9.22";
|
|
2905
2904
|
var UV_PYTHON_PATH_PREFIX = "/uv/python/";
|
|
2906
2905
|
var UV_PYTHON_DOWNLOADS_MODE = "automatic";
|
|
2907
|
-
var UV_CACHE_DIR_SUBPATH = [".vercel", "python", "cache", "uv"];
|
|
2908
2906
|
var isWin = process.platform === "win32";
|
|
2909
2907
|
var uvExec = isWin ? "uv.exe" : "uv";
|
|
2910
2908
|
function findUvInPath() {
|
|
2911
2909
|
return import_which.default.sync("uv", { nothrow: true });
|
|
2912
2910
|
}
|
|
2913
|
-
function getUvCacheDir(workPath) {
|
|
2914
|
-
return (0, import_path.join)(workPath, ...UV_CACHE_DIR_SUBPATH);
|
|
2915
|
-
}
|
|
2916
2911
|
var UvRunner = class {
|
|
2917
|
-
constructor(uvPath
|
|
2912
|
+
constructor(uvPath) {
|
|
2918
2913
|
this.uvPath = uvPath;
|
|
2919
|
-
this.uvCacheDir = uvCacheDir;
|
|
2920
2914
|
}
|
|
2921
2915
|
getPath() {
|
|
2922
2916
|
return this.uvPath;
|
|
@@ -2993,7 +2987,7 @@ var UvRunner = class {
|
|
|
2993
2987
|
try {
|
|
2994
2988
|
await (0, import_execa.default)(this.uvPath, args, {
|
|
2995
2989
|
cwd: projectDir,
|
|
2996
|
-
env: getProtectedUvEnv(process.env
|
|
2990
|
+
env: getProtectedUvEnv(process.env)
|
|
2997
2991
|
});
|
|
2998
2992
|
} catch (err) {
|
|
2999
2993
|
const error = new Error(
|
|
@@ -3058,7 +3052,7 @@ var UvRunner = class {
|
|
|
3058
3052
|
const binDir = isWin ? (0, import_path.join)(venvPath, "Scripts") : (0, import_path.join)(venvPath, "bin");
|
|
3059
3053
|
const existingPath = process.env.PATH || "";
|
|
3060
3054
|
return {
|
|
3061
|
-
...getProtectedUvEnv(process.env
|
|
3055
|
+
...getProtectedUvEnv(process.env),
|
|
3062
3056
|
VIRTUAL_ENV: venvPath,
|
|
3063
3057
|
PATH: existingPath ? `${binDir}${import_path2.delimiter}${existingPath}` : binDir
|
|
3064
3058
|
};
|
|
@@ -3165,15 +3159,11 @@ async function getUvBinaryOrInstall(pythonPath) {
|
|
|
3165
3159
|
function filterUnsafeUvPipArgs(args) {
|
|
3166
3160
|
return args.filter((arg) => arg !== "--no-warn-script-location");
|
|
3167
3161
|
}
|
|
3168
|
-
function getProtectedUvEnv(baseEnv = process.env
|
|
3169
|
-
|
|
3162
|
+
function getProtectedUvEnv(baseEnv = process.env) {
|
|
3163
|
+
return {
|
|
3170
3164
|
...baseEnv,
|
|
3171
3165
|
UV_PYTHON_DOWNLOADS: UV_PYTHON_DOWNLOADS_MODE
|
|
3172
3166
|
};
|
|
3173
|
-
if (uvCacheDir) {
|
|
3174
|
-
env.UV_CACHE_DIR = uvCacheDir;
|
|
3175
|
-
}
|
|
3176
|
-
return env;
|
|
3177
3167
|
}
|
|
3178
3168
|
var UV_BUNDLE_DIR = "_uv";
|
|
3179
3169
|
async function getUvBinaryForBundling(pythonPath) {
|
|
@@ -3212,9 +3202,9 @@ function useVirtualEnv(workPath, env, systemPython) {
|
|
|
3212
3202
|
}
|
|
3213
3203
|
return { pythonCmd };
|
|
3214
3204
|
}
|
|
3215
|
-
function createVenvEnv(venvPath, baseEnv = process.env
|
|
3205
|
+
function createVenvEnv(venvPath, baseEnv = process.env) {
|
|
3216
3206
|
const env = {
|
|
3217
|
-
...getProtectedUvEnv(baseEnv
|
|
3207
|
+
...getProtectedUvEnv(baseEnv),
|
|
3218
3208
|
VIRTUAL_ENV: venvPath
|
|
3219
3209
|
};
|
|
3220
3210
|
const binDir = getVenvBinDir(venvPath);
|
|
@@ -3226,7 +3216,6 @@ async function ensureVenv({
|
|
|
3226
3216
|
pythonPath,
|
|
3227
3217
|
venvPath,
|
|
3228
3218
|
uvPath,
|
|
3229
|
-
uvCacheDir,
|
|
3230
3219
|
quiet
|
|
3231
3220
|
}) {
|
|
3232
3221
|
const marker = (0, import_path3.join)(venvPath, "pyvenv.cfg");
|
|
@@ -3240,9 +3229,7 @@ async function ensureVenv({
|
|
|
3240
3229
|
console.log(`Creating virtual environment at "${venvPath}"...`);
|
|
3241
3230
|
}
|
|
3242
3231
|
if (uvPath) {
|
|
3243
|
-
await (0, import_execa2.default)(uvPath, ["venv", venvPath]
|
|
3244
|
-
env: getProtectedUvEnv(process.env, uvCacheDir)
|
|
3245
|
-
});
|
|
3232
|
+
await (0, import_execa2.default)(uvPath, ["venv", venvPath]);
|
|
3246
3233
|
} else {
|
|
3247
3234
|
await (0, import_execa2.default)(pythonPath, ["-m", "venv", venvPath]);
|
|
3248
3235
|
}
|
|
@@ -3749,7 +3736,7 @@ async function pipInstall(pipPath, uvPath, workPath, args, targetDir) {
|
|
|
3749
3736
|
try {
|
|
3750
3737
|
await (0, import_execa3.default)(uvPath, uvArgs, {
|
|
3751
3738
|
cwd: workPath,
|
|
3752
|
-
env: getProtectedUvEnv(
|
|
3739
|
+
env: getProtectedUvEnv()
|
|
3753
3740
|
});
|
|
3754
3741
|
return;
|
|
3755
3742
|
} catch (err) {
|
|
@@ -4716,12 +4703,7 @@ async function getMultiServicePythonRunner(workPath, env, systemPython, uvPath)
|
|
|
4716
4703
|
return { command: pythonCmd, args: [] };
|
|
4717
4704
|
}
|
|
4718
4705
|
const venvPath = (0, import_path8.join)(workPath, ".venv");
|
|
4719
|
-
await ensureVenv({
|
|
4720
|
-
pythonPath: systemPython,
|
|
4721
|
-
venvPath,
|
|
4722
|
-
uvPath,
|
|
4723
|
-
quiet: true
|
|
4724
|
-
});
|
|
4706
|
+
await ensureVenv({ pythonPath: systemPython, venvPath, uvPath, quiet: true });
|
|
4725
4707
|
(0, import_build_utils8.debug)(`Created virtualenv at ${venvPath} for multi-service dev`);
|
|
4726
4708
|
const pythonBin = getVenvPythonBin(venvPath);
|
|
4727
4709
|
const binDir = getVenvBinDir(venvPath);
|
|
@@ -5584,12 +5566,10 @@ var build = async ({
|
|
|
5584
5566
|
}
|
|
5585
5567
|
fsFiles = await (0, import_build_utils13.glob)("**", workPath);
|
|
5586
5568
|
const venvPath = (0, import_path12.join)(workPath, ".vercel", "python", ".venv");
|
|
5587
|
-
const uvCacheDir = getUvCacheDir(workPath);
|
|
5588
5569
|
await builderSpan.child("vc.builder.python.venv").trace(async () => {
|
|
5589
5570
|
await ensureVenv({
|
|
5590
5571
|
pythonPath: pythonVersion.pythonPath,
|
|
5591
|
-
venvPath
|
|
5592
|
-
uvCacheDir
|
|
5572
|
+
venvPath
|
|
5593
5573
|
});
|
|
5594
5574
|
});
|
|
5595
5575
|
if ((0, import_build_utils13.isPythonFramework)(framework)) {
|
|
@@ -5618,14 +5598,14 @@ var build = async ({
|
|
|
5618
5598
|
}
|
|
5619
5599
|
}
|
|
5620
5600
|
const baseEnv = spawnEnv || process.env;
|
|
5621
|
-
const pythonEnv = createVenvEnv(venvPath, baseEnv
|
|
5601
|
+
const pythonEnv = createVenvEnv(venvPath, baseEnv);
|
|
5622
5602
|
pythonEnv.VERCEL_PYTHON_VENV_PATH = venvPath;
|
|
5623
5603
|
let assumeDepsInstalled = false;
|
|
5624
5604
|
let uv;
|
|
5625
5605
|
try {
|
|
5626
5606
|
const uvPath = await getUvBinaryOrInstall(pythonVersion.pythonPath);
|
|
5627
5607
|
console.log(`Using uv at "${uvPath}"`);
|
|
5628
|
-
uv = new UvRunner(uvPath
|
|
5608
|
+
uv = new UvRunner(uvPath);
|
|
5629
5609
|
} catch (err) {
|
|
5630
5610
|
console.log("Failed to install or locate uv");
|
|
5631
5611
|
throw new Error(
|
|
@@ -5882,41 +5862,6 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
5882
5862
|
});
|
|
5883
5863
|
return { output };
|
|
5884
5864
|
};
|
|
5885
|
-
async function readBuildOutputV3Config(workPath) {
|
|
5886
|
-
try {
|
|
5887
|
-
const configPath = (0, import_path12.join)(workPath, ".vercel", "output", "config.json");
|
|
5888
|
-
return JSON.parse(await import_fs10.default.promises.readFile(configPath, "utf8"));
|
|
5889
|
-
} catch (err) {
|
|
5890
|
-
if (err.code !== "ENOENT") {
|
|
5891
|
-
throw err;
|
|
5892
|
-
}
|
|
5893
|
-
}
|
|
5894
|
-
return void 0;
|
|
5895
|
-
}
|
|
5896
|
-
var prepareCache = async ({
|
|
5897
|
-
repoRootPath,
|
|
5898
|
-
workPath
|
|
5899
|
-
}) => {
|
|
5900
|
-
const cacheFiles = {};
|
|
5901
|
-
const root = repoRootPath || workPath;
|
|
5902
|
-
const ignore = ["**/*.pyc", "**/__pycache__/**"];
|
|
5903
|
-
const configV3 = await readBuildOutputV3Config(workPath);
|
|
5904
|
-
if (configV3?.cache && Array.isArray(configV3.cache)) {
|
|
5905
|
-
for (const cacheGlob of configV3.cache) {
|
|
5906
|
-
Object.assign(cacheFiles, await (0, import_build_utils13.glob)(cacheGlob, workPath));
|
|
5907
|
-
}
|
|
5908
|
-
return cacheFiles;
|
|
5909
|
-
}
|
|
5910
|
-
Object.assign(
|
|
5911
|
-
cacheFiles,
|
|
5912
|
-
await (0, import_build_utils13.glob)("**/.vercel/python/.venv/**", { cwd: root, ignore })
|
|
5913
|
-
);
|
|
5914
|
-
Object.assign(
|
|
5915
|
-
cacheFiles,
|
|
5916
|
-
await (0, import_build_utils13.glob)("**/.vercel/python/cache/uv/**", { cwd: root, ignore })
|
|
5917
|
-
);
|
|
5918
|
-
return cacheFiles;
|
|
5919
|
-
};
|
|
5920
5865
|
var shouldServe = (opts) => {
|
|
5921
5866
|
const framework = opts.config.framework;
|
|
5922
5867
|
if ((0, import_build_utils13.isPythonFramework)(framework)) {
|
|
@@ -5954,7 +5899,6 @@ function hasProp(obj, key) {
|
|
|
5954
5899
|
downloadFilesInWorkPath,
|
|
5955
5900
|
installRequirement,
|
|
5956
5901
|
installRequirementsFile,
|
|
5957
|
-
prepareCache,
|
|
5958
5902
|
runFrameworkHook,
|
|
5959
5903
|
shouldServe,
|
|
5960
5904
|
startDevServer,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/python",
|
|
3
|
-
"version": "6.22.
|
|
3
|
+
"version": "6.22.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"which": "3.0.0",
|
|
36
36
|
"get-port": "5.1.1",
|
|
37
37
|
"is-port-reachable": "3.1.0",
|
|
38
|
-
"@vercel/python-runtime": "0.7.0",
|
|
39
38
|
"@vercel/build-utils": "13.8.0",
|
|
40
|
-
"@vercel/error-utils": "2.0.3"
|
|
39
|
+
"@vercel/error-utils": "2.0.3",
|
|
40
|
+
"@vercel/python-runtime": "0.7.0"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "node ../../utils/build-builder.mjs",
|