MCPcopy Create free account
hub / github.com/vercel/vercel / runCompileAllAndFillBytecode

Function runCompileAllAndFillBytecode

packages/python/src/index.ts:1099–1160  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1097 // present in the bundle, so excluded source can't re-enter as .pyc.
1098 // Shared by the direct-bundle path and the generateBundle Hive fallback.
1099 const runCompileAllAndFillBytecode = async () => {
1100 await builderSpan
1101 .child('vc.builder.python.compileall')
1102 .trace(async compileSpan => {
1103 const sitePackageDirs = (
1104 await getVenvSitePackagesDirs(venvPath)
1105 ).filter(d => fs.existsSync(d));
1106 const pythonBin = getVenvPythonBin(venvPath);
1107
1108 console.log('Compiling Python application bytecode...');
1109 await runCompileAll({
1110 pythonBin,
1111 filesOrDirectories: [workPath],
1112 env: pythonEnv,
1113 excludeRegex: getCompileAllAppExcludeRegex(workPath),
1114 });
1115
1116 console.log('Compiling Python dependency bytecode...');
1117 await runCompileAll({
1118 pythonBin,
1119 filesOrDirectories: sitePackageDirs,
1120 env: pythonEnv,
1121 });
1122
1123 compileSpan.setAttributes({
1124 'python.compileall.enabled': 'true',
1125 'python.compileall.sitePackageDirectoryCount': String(
1126 sitePackageDirs.length
1127 ),
1128 });
1129 });
1130
1131 // Fill remaining capacity up to the large-function size limit.
1132 const currentSize = await calculateBundleSize(files);
1133 let remainingCapacity =
1134 MAX_LARGE_FUNCTION_UNCOMPRESSED_SIZE - currentSize;
1135
1136 if (pythonVersion.major != null && pythonVersion.minor != null) {
1137 const appBytecodeInfo = await collectAppBytecodeFiles({
1138 workPath,
1139 files,
1140 pythonMajor: pythonVersion.major,
1141 pythonMinor: pythonVersion.minor,
1142 });
1143 remainingCapacity = addBytecodeWithinCapacity(
1144 files,
1145 appBytecodeInfo,
1146 remainingCapacity
1147 );
1148 }
1149
1150 const vendorBytecodeInfo = await depExternalizer.collectBytecodeFiles({
1151 vendorDirName: vendorDir,
1152 });
1153 await addVendorBytecodeWithinCapacity({
1154 files,
1155 depExternalizer,
1156 vendorDir,

Callers 1

buildFunction · 0.85

Calls 15

getVenvSitePackagesDirsFunction · 0.90
getVenvPythonBinFunction · 0.90
runCompileAllFunction · 0.90
calculateBundleSizeFunction · 0.90
collectAppBytecodeFilesFunction · 0.90
childMethod · 0.80
filterMethod · 0.80
setAttributesMethod · 0.80
traceMethod · 0.45

Tested by

no test coverage detected