[python] Add warning for deprecated version (#7053)

- Print warning when python 3.6 is selected
- Print warning when invalid python version is selected
This commit is contained in:
Steven
2021-11-22 18:36:30 -05:00
committed by GitHub
parent 5d85bb1426
commit 19831593ce
9 changed files with 59 additions and 27 deletions

View File

@@ -114,10 +114,24 @@ export const build = async ({
try {
const json = await readFile(join(pipfileLockDir, 'Pipfile.lock'), 'utf8');
const obj = JSON.parse(json);
if (!meta.isDev && obj?._meta?.requires?.python_version === '3.6') {
pipPath = 'pip3.6';
pythonPath = 'python3.6';
pythonRuntime = 'python3.6';
const version = obj?._meta?.requires?.python_version;
if (!meta.isDev) {
if (version === '3.6') {
pipPath = 'pip3.6';
pythonPath = 'python3.6';
pythonRuntime = 'python3.6';
console.warn(
`Warning: Python version "${version}" detected in Pipfile.lock will reach End-Of-Life December 2021. Please upgrade. http://vercel.link/python-version`
);
} else if (version === '3.9') {
pipPath = 'pip3.9';
pythonPath = 'python3.9';
pythonRuntime = 'python3.9';
} else {
console.warn(
`Warning: Invalid Python version "${version}" detected in Pipfile.lock will be ignored. http://vercel.link/python-version`
);
}
}
} catch (err) {
throw new NowBuildError({

View File

@@ -1,5 +0,0 @@
{
"version": 2,
"builds": [{ "src": "index.py", "use": "@vercel/python" }],
"probes": [{ "path": "/", "mustContain": "wsgi:RANDOMNESS_PLACEHOLDER" }]
}

View File

@@ -0,0 +1,11 @@
{
"version": 2,
"builds": [{ "src": "index.py", "use": "@vercel/python" }],
"probes": [
{
"path": "/",
"mustContain": "wsgi:RANDOMNESS_PLACEHOLDER",
"logMustContain": "Warning: Python version \"3.6\" detected in Pipfile.lock will reach End-Of-Life December 2021. Please upgrade."
}
]
}

View File

@@ -1,8 +0,0 @@
{
"version": 2,
"builds": [{ "src": "index.py", "use": "@vercel/python" }],
"env": {
"RANDOMNESS": "RANDOMNESS_PLACEHOLDER"
},
"probes": [{ "path": "/", "mustContain": "RANDOMNESS_PLACEHOLDER:env" }]
}

View File

@@ -0,0 +1,14 @@
{
"version": 2,
"builds": [{ "src": "index.py", "use": "@vercel/python" }],
"env": {
"RANDOMNESS": "RANDOMNESS_PLACEHOLDER"
},
"probes": [
{
"path": "/",
"mustContain": "RANDOMNESS_PLACEHOLDER:env",
"logMustContain": "Warning: Python version \"3.6\" detected in Pipfile.lock will reach End-Of-Life December 2021. Please upgrade."
}
]
}

View File

@@ -1,5 +0,0 @@
{
"version": 2,
"builds": [{ "src": "**/**.py", "use": "@vercel/python" }],
"probes": [{ "path": "/", "mustContain": "pip:RANDOMNESS_PLACEHOLDER" }]
}

View File

@@ -0,0 +1,11 @@
{
"version": 2,
"builds": [{ "src": "**/**.py", "use": "@vercel/python" }],
"probes": [
{
"path": "/",
"mustContain": "pip:RANDOMNESS_PLACEHOLDER",
"logMustContain": "Warning: Invalid Python version \"3.7\" detected in Pipfile.lock will be ignored."
}
]
}