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

Function getDefaultPythonVersion

packages/python/src/version.ts:84–110  ·  view source on GitHub ↗
({
  isDev,
}: {
  isDev?: boolean;
})

Source from the content-addressed store, hash-verified

82 * or an unsupported version is requested.
83 */
84export function getDefaultPythonVersion({
85 isDev,
86}: {
87 isDev?: boolean;
88}): PythonVersion {
89 if (isDev) {
90 return getDevPythonVersion();
91 }
92
93 const defaultOption = allOptions.find(
94 opt => versionsEqual(opt, DEFAULT_PYTHON_VERSION) && isInstalled(opt)
95 );
96 if (defaultOption) {
97 return defaultOption;
98 }
99
100 // Fallback to the latest installed version if the default isn't available
101 const selection = allOptions.find(isInstalled);
102 if (!selection) {
103 throw new NowBuildError({
104 code: 'PYTHON_NOT_FOUND',
105 link: 'https://vercel.link/python-version',
106 message: `Unable to find any supported Python versions.`,
107 });
108 }
109 return selection;
110}
111
112function versionsEqual(a: PythonVersion, b: PythonVersion): boolean {
113 return a.major === b.major && a.minor === b.minor;

Callers 2

startDevServerFunction · 0.90
resolvePythonVersionFunction · 0.85

Calls 4

getDevPythonVersionFunction · 0.85
versionsEqualFunction · 0.85
isInstalledFunction · 0.70
findMethod · 0.45

Tested by

no test coverage detected