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

Function readVenvPythonVersion

packages/python/src/utils.ts:67–77  ·  view source on GitHub ↗

* Parse the `version` field from a pyvenv.cfg file and return the * "major.minor" string. Returns null if the file * cannot be read or the version line is missing.

(
  pyvenvCfgPath: string
)

Source from the content-addressed store, hash-verified

65 * cannot be read or the version line is missing.
66 */
67async function readVenvPythonVersion(
68 pyvenvCfgPath: string
69): Promise<string | null> {
70 try {
71 const content = await fs.promises.readFile(pyvenvCfgPath, 'utf-8');
72 const match = content.match(/^version\s*=\s*(\d+)\.(\d+)/m);
73 return match ? `${match[1]}.${match[2]}` : null;
74 } catch {
75 return null;
76 }
77}
78
79export async function ensureVenv({
80 pythonVersion,

Callers 1

ensureVenvFunction · 0.85

Calls 1

matchMethod · 0.45

Tested by

no test coverage detected