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

Function derivePycPath

packages/python/src/compileall.ts:96–108  ·  view source on GitHub ↗
(
  pyRelPath: string,
  pythonMajor: number,
  pythonMinor: number
)

Source from the content-addressed store, hash-verified

94 * Returns `null` if the input is not a `.py` file.
95 */
96export function derivePycPath(
97 pyRelPath: string,
98 pythonMajor: number,
99 pythonMinor: number
100): string | null {
101 if (!pyRelPath.endsWith('.py')) return null;
102
103 const lastSlash = pyRelPath.lastIndexOf('/');
104 const dir = lastSlash === -1 ? '' : pyRelPath.slice(0, lastSlash + 1);
105 const baseName = pyRelPath.slice(lastSlash + 1, -3); // strip ".py"
106
107 return `${dir}__pycache__/${baseName}.cpython-${pythonMajor}${pythonMinor}.pyc`;
108}
109
110export interface BytecodeCollectionResult {
111 /** FileFsRef entries for .pyc files, keyed by bundle-relative path. */

Callers 3

compileall.test.tsFile · 0.90
collectBytecodeFilesMethod · 0.90
collectAppBytecodeFilesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected