@vercel/python 2.2.3-canary.4 → 2.2.3-canary.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +92 -31
- package/dist/version.d.ts +15 -0
- package/package.json +6 -4
package/dist/index.js
CHANGED
|
@@ -3522,6 +3522,7 @@ Object.defineProperty(exports, "shouldServe", ({ enumerable: true, get: function
|
|
|
3522
3522
|
const install_1 = __webpack_require__(95);
|
|
3523
3523
|
Object.defineProperty(exports, "installRequirement", ({ enumerable: true, get: function () { return install_1.installRequirement; } }));
|
|
3524
3524
|
Object.defineProperty(exports, "installRequirementsFile", ({ enumerable: true, get: function () { return install_1.installRequirementsFile; } }));
|
|
3525
|
+
const version_1 = __webpack_require__(255);
|
|
3525
3526
|
async function pipenvConvert(cmd, srcDir) {
|
|
3526
3527
|
build_utils_1.debug('Running pipfile2req...');
|
|
3527
3528
|
try {
|
|
@@ -3553,9 +3554,7 @@ async function downloadFilesInWorkPath({ entrypoint, workPath, files, meta = {},
|
|
|
3553
3554
|
exports.downloadFilesInWorkPath = downloadFilesInWorkPath;
|
|
3554
3555
|
const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, config, }) => {
|
|
3555
3556
|
var _a, _b;
|
|
3556
|
-
let
|
|
3557
|
-
let pythonPath = meta.isDev ? 'python3' : 'python3.9';
|
|
3558
|
-
let pythonRuntime = meta.isDev ? 'python3' : 'python3.9';
|
|
3557
|
+
let pythonVersion = version_1.getLatestPythonVersion(meta);
|
|
3559
3558
|
workPath = await downloadFilesInWorkPath({
|
|
3560
3559
|
workPath,
|
|
3561
3560
|
files: originalFiles,
|
|
@@ -3582,8 +3581,8 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
|
|
|
3582
3581
|
}
|
|
3583
3582
|
console.log('Installing required dependencies...');
|
|
3584
3583
|
await install_1.installRequirement({
|
|
3585
|
-
pythonPath,
|
|
3586
|
-
pipPath,
|
|
3584
|
+
pythonPath: pythonVersion.pythonPath,
|
|
3585
|
+
pipPath: pythonVersion.pipPath,
|
|
3587
3586
|
dependency: 'werkzeug',
|
|
3588
3587
|
version: '1.0.1',
|
|
3589
3588
|
workPath,
|
|
@@ -3601,23 +3600,10 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
|
|
|
3601
3600
|
try {
|
|
3602
3601
|
const json = await readFile(path_1.join(pipfileLockDir, 'Pipfile.lock'), 'utf8');
|
|
3603
3602
|
const obj = JSON.parse(json);
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
pythonPath = 'python3.6';
|
|
3609
|
-
pythonRuntime = 'python3.6';
|
|
3610
|
-
console.warn(`Warning: Python version "${version}" detected in Pipfile.lock will reach End-Of-Life December 2021. Please upgrade. http://vercel.link/python-version`);
|
|
3611
|
-
}
|
|
3612
|
-
else if (version === '3.9') {
|
|
3613
|
-
pipPath = 'pip3.9';
|
|
3614
|
-
pythonPath = 'python3.9';
|
|
3615
|
-
pythonRuntime = 'python3.9';
|
|
3616
|
-
}
|
|
3617
|
-
else {
|
|
3618
|
-
console.warn(`Warning: Invalid Python version "${version}" detected in Pipfile.lock will be ignored. http://vercel.link/python-version`);
|
|
3619
|
-
}
|
|
3620
|
-
}
|
|
3603
|
+
pythonVersion = version_1.getSupportedPythonVersion({
|
|
3604
|
+
isDev: meta.isDev,
|
|
3605
|
+
pipLockPythonVersion: (_b = (_a = obj === null || obj === void 0 ? void 0 : obj._meta) === null || _a === void 0 ? void 0 : _a.requires) === null || _b === void 0 ? void 0 : _b.python_version,
|
|
3606
|
+
});
|
|
3621
3607
|
}
|
|
3622
3608
|
catch (err) {
|
|
3623
3609
|
throw new build_utils_1.NowBuildError({
|
|
@@ -3631,8 +3617,8 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
|
|
|
3631
3617
|
// it into a separate folder.
|
|
3632
3618
|
const tempDir = await build_utils_1.getWriteableDirectory();
|
|
3633
3619
|
await install_1.installRequirement({
|
|
3634
|
-
pythonPath,
|
|
3635
|
-
pipPath,
|
|
3620
|
+
pythonPath: pythonVersion.pythonPath,
|
|
3621
|
+
pipPath: pythonVersion.pipPath,
|
|
3636
3622
|
dependency: 'pipfile-requirements',
|
|
3637
3623
|
version: '0.3.0',
|
|
3638
3624
|
workPath: tempDir,
|
|
@@ -3651,8 +3637,8 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
|
|
|
3651
3637
|
build_utils_1.debug('Found local "requirements.txt"');
|
|
3652
3638
|
const requirementsTxtPath = fsFiles[requirementsTxt].fsPath;
|
|
3653
3639
|
await install_1.installRequirementsFile({
|
|
3654
|
-
pythonPath,
|
|
3655
|
-
pipPath,
|
|
3640
|
+
pythonPath: pythonVersion.pythonPath,
|
|
3641
|
+
pipPath: pythonVersion.pipPath,
|
|
3656
3642
|
filePath: requirementsTxtPath,
|
|
3657
3643
|
workPath,
|
|
3658
3644
|
meta,
|
|
@@ -3662,8 +3648,8 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
|
|
|
3662
3648
|
build_utils_1.debug('Found global "requirements.txt"');
|
|
3663
3649
|
const requirementsTxtPath = fsFiles['requirements.txt'].fsPath;
|
|
3664
3650
|
await install_1.installRequirementsFile({
|
|
3665
|
-
pythonPath,
|
|
3666
|
-
pipPath,
|
|
3651
|
+
pythonPath: pythonVersion.pythonPath,
|
|
3652
|
+
pipPath: pythonVersion.pipPath,
|
|
3667
3653
|
filePath: requirementsTxtPath,
|
|
3668
3654
|
workPath,
|
|
3669
3655
|
meta,
|
|
@@ -3684,8 +3670,6 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
|
|
|
3684
3670
|
// somethig else
|
|
3685
3671
|
const handlerPyFilename = 'vc__handler__python';
|
|
3686
3672
|
await writeFile(path_1.join(workPath, `${handlerPyFilename}.py`), handlerPyContents);
|
|
3687
|
-
// Use the system-installed version of `python3` when running via `vercel dev`
|
|
3688
|
-
const runtime = meta.isDev ? 'python3' : pythonRuntime;
|
|
3689
3673
|
const globOptions = {
|
|
3690
3674
|
cwd: workPath,
|
|
3691
3675
|
ignore: config && typeof config.excludeFiles === 'string'
|
|
@@ -3695,7 +3679,7 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
|
|
|
3695
3679
|
const lambda = await build_utils_1.createLambda({
|
|
3696
3680
|
files: await build_utils_1.glob('**', globOptions),
|
|
3697
3681
|
handler: `${handlerPyFilename}.vc_handler`,
|
|
3698
|
-
runtime,
|
|
3682
|
+
runtime: pythonVersion.runtime,
|
|
3699
3683
|
environment: {},
|
|
3700
3684
|
});
|
|
3701
3685
|
return { output: lambda };
|
|
@@ -3811,6 +3795,83 @@ async function installRequirementsFile({ pythonPath, pipPath, filePath, workPath
|
|
|
3811
3795
|
exports.installRequirementsFile = installRequirementsFile;
|
|
3812
3796
|
|
|
3813
3797
|
|
|
3798
|
+
/***/ }),
|
|
3799
|
+
|
|
3800
|
+
/***/ 255:
|
|
3801
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3802
|
+
|
|
3803
|
+
"use strict";
|
|
3804
|
+
|
|
3805
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3806
|
+
exports.getSupportedPythonVersion = exports.getLatestPythonVersion = void 0;
|
|
3807
|
+
const build_utils_1 = __webpack_require__(445);
|
|
3808
|
+
// The order must be most recent first
|
|
3809
|
+
const allOptions = [
|
|
3810
|
+
{
|
|
3811
|
+
version: '3.9',
|
|
3812
|
+
pipPath: 'pip3.9',
|
|
3813
|
+
pythonPath: 'python3.9',
|
|
3814
|
+
runtime: 'python3.9',
|
|
3815
|
+
},
|
|
3816
|
+
{
|
|
3817
|
+
version: '3.6',
|
|
3818
|
+
pipPath: 'pip3.6',
|
|
3819
|
+
pythonPath: 'python3.6',
|
|
3820
|
+
runtime: 'python3.6',
|
|
3821
|
+
discontinueDate: new Date('2022-07-18'),
|
|
3822
|
+
},
|
|
3823
|
+
];
|
|
3824
|
+
const upstreamProvider = 'This change is the result of a decision made by an upstream infrastructure provider (AWS)';
|
|
3825
|
+
function getDevPythonVersion() {
|
|
3826
|
+
// Use the system-installed version of `python3` when running `vercel dev`
|
|
3827
|
+
return {
|
|
3828
|
+
version: '3',
|
|
3829
|
+
pipPath: 'pip3',
|
|
3830
|
+
pythonPath: 'python3',
|
|
3831
|
+
runtime: 'python3',
|
|
3832
|
+
};
|
|
3833
|
+
}
|
|
3834
|
+
function getLatestPythonVersion({ isDev, }) {
|
|
3835
|
+
if (isDev) {
|
|
3836
|
+
return getDevPythonVersion();
|
|
3837
|
+
}
|
|
3838
|
+
return allOptions[0];
|
|
3839
|
+
}
|
|
3840
|
+
exports.getLatestPythonVersion = getLatestPythonVersion;
|
|
3841
|
+
function getSupportedPythonVersion({ isDev, pipLockPythonVersion, }) {
|
|
3842
|
+
if (isDev) {
|
|
3843
|
+
return getDevPythonVersion();
|
|
3844
|
+
}
|
|
3845
|
+
let selection = getLatestPythonVersion({ isDev: false });
|
|
3846
|
+
if (typeof pipLockPythonVersion === 'string') {
|
|
3847
|
+
const found = allOptions.find(o => o.version === pipLockPythonVersion);
|
|
3848
|
+
if (found) {
|
|
3849
|
+
selection = found;
|
|
3850
|
+
}
|
|
3851
|
+
else {
|
|
3852
|
+
console.warn(`Warning: Python version "${pipLockPythonVersion}" detected in Pipfile.lock is invalid and will be ignored. http://vercel.link/python-version`);
|
|
3853
|
+
}
|
|
3854
|
+
}
|
|
3855
|
+
if (isDiscontinued(selection)) {
|
|
3856
|
+
throw new build_utils_1.NowBuildError({
|
|
3857
|
+
code: 'BUILD_UTILS_PYTHON_VERSION_DISCONTINUED',
|
|
3858
|
+
link: 'http://vercel.link/python-version',
|
|
3859
|
+
message: `Python version "${selection.version}" detected in Pipfile.lock is discontinued and must be upgraded. ${upstreamProvider}.`,
|
|
3860
|
+
});
|
|
3861
|
+
}
|
|
3862
|
+
if (selection.discontinueDate) {
|
|
3863
|
+
const d = selection.discontinueDate.toISOString().split('T')[0];
|
|
3864
|
+
console.warn(`Error: Python version "${selection.version}" detected in Pipfile.lock is deprecated. Deployments created on or after ${d} will fail to build. ${upstreamProvider}. http://vercel.link/python-version`);
|
|
3865
|
+
}
|
|
3866
|
+
return selection;
|
|
3867
|
+
}
|
|
3868
|
+
exports.getSupportedPythonVersion = getSupportedPythonVersion;
|
|
3869
|
+
function isDiscontinued({ discontinueDate }) {
|
|
3870
|
+
const today = Date.now();
|
|
3871
|
+
return discontinueDate !== undefined && discontinueDate.getTime() <= today;
|
|
3872
|
+
}
|
|
3873
|
+
|
|
3874
|
+
|
|
3814
3875
|
/***/ }),
|
|
3815
3876
|
|
|
3816
3877
|
/***/ 445:
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface PythonVersion {
|
|
2
|
+
version: string;
|
|
3
|
+
pipPath: string;
|
|
4
|
+
pythonPath: string;
|
|
5
|
+
runtime: string;
|
|
6
|
+
discontinueDate?: Date;
|
|
7
|
+
}
|
|
8
|
+
export declare function getLatestPythonVersion({ isDev, }: {
|
|
9
|
+
isDev?: boolean;
|
|
10
|
+
}): PythonVersion;
|
|
11
|
+
export declare function getSupportedPythonVersion({ isDev, pipLockPythonVersion, }: {
|
|
12
|
+
isDev?: boolean;
|
|
13
|
+
pipLockPythonVersion: string | undefined;
|
|
14
|
+
}): PythonVersion;
|
|
15
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/python",
|
|
3
|
-
"version": "2.2.3-canary.
|
|
3
|
+
"version": "2.2.3-canary.5",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
|
|
@@ -15,15 +15,17 @@
|
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "node build",
|
|
18
|
-
"test-
|
|
18
|
+
"test-unit": "jest --env node --verbose --runInBand --bail test/unit.test.ts ",
|
|
19
|
+
"test-integration-once": "jest --env node --verbose --runInBand --bail test/integration.test.ts",
|
|
19
20
|
"prepublishOnly": "node build"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
|
22
23
|
"@types/execa": "^0.9.0",
|
|
23
|
-
"@
|
|
24
|
+
"@types/jest": "27.4.1",
|
|
25
|
+
"@vercel/build-utils": "2.15.2-canary.5",
|
|
24
26
|
"@vercel/ncc": "0.24.0",
|
|
25
27
|
"execa": "^1.0.0",
|
|
26
28
|
"typescript": "4.3.4"
|
|
27
29
|
},
|
|
28
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "438576fc7c392e754d1fc85fc1d9f3122e80d015"
|
|
29
31
|
}
|