@vercel/python 3.1.58 → 3.1.60

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.
Files changed (2) hide show
  1. package/dist/index.js +42 -42
  2. package/package.json +5 -6
package/dist/index.js CHANGED
@@ -3526,8 +3526,8 @@ const path_1 = __webpack_require__(622);
3526
3526
  const execa_1 = __importDefault(__webpack_require__(389));
3527
3527
  const fs_1 = __importDefault(__webpack_require__(747));
3528
3528
  const util_1 = __webpack_require__(669);
3529
- const readFile = util_1.promisify(fs_1.default.readFile);
3530
- const writeFile = util_1.promisify(fs_1.default.writeFile);
3529
+ const readFile = (0, util_1.promisify)(fs_1.default.readFile);
3530
+ const writeFile = (0, util_1.promisify)(fs_1.default.writeFile);
3531
3531
  const build_utils_1 = __webpack_require__(445);
3532
3532
  Object.defineProperty(exports, "shouldServe", ({ enumerable: true, get: function () { return build_utils_1.shouldServe; } }));
3533
3533
  const install_1 = __webpack_require__(526);
@@ -3535,13 +3535,13 @@ Object.defineProperty(exports, "installRequirement", ({ enumerable: true, get: f
3535
3535
  Object.defineProperty(exports, "installRequirementsFile", ({ enumerable: true, get: function () { return install_1.installRequirementsFile; } }));
3536
3536
  const version_1 = __webpack_require__(127);
3537
3537
  async function pipenvConvert(cmd, srcDir) {
3538
- build_utils_1.debug('Running pipfile2req...');
3538
+ (0, build_utils_1.debug)('Running pipfile2req...');
3539
3539
  try {
3540
3540
  const out = await execa_1.default.stdout(cmd, [], {
3541
3541
  cwd: srcDir,
3542
3542
  });
3543
- build_utils_1.debug('Contents of requirements.txt is: ' + out);
3544
- fs_1.default.writeFileSync(path_1.join(srcDir, 'requirements.txt'), out);
3543
+ (0, build_utils_1.debug)('Contents of requirements.txt is: ' + out);
3544
+ fs_1.default.writeFileSync((0, path_1.join)(srcDir, 'requirements.txt'), out);
3545
3545
  }
3546
3546
  catch (err) {
3547
3547
  console.log('Failed to run "pipfile2req"');
@@ -3550,21 +3550,21 @@ async function pipenvConvert(cmd, srcDir) {
3550
3550
  }
3551
3551
  exports.version = 3;
3552
3552
  async function downloadFilesInWorkPath({ entrypoint, workPath, files, meta = {}, }) {
3553
- build_utils_1.debug('Downloading user files...');
3554
- let downloadedFiles = await build_utils_1.download(files, workPath, meta);
3553
+ (0, build_utils_1.debug)('Downloading user files...');
3554
+ let downloadedFiles = await (0, build_utils_1.download)(files, workPath, meta);
3555
3555
  if (meta.isDev) {
3556
3556
  // Old versions of the CLI don't assign this property
3557
- const { devCacheDir = path_1.join(workPath, '.now', 'cache') } = meta;
3558
- const destCache = path_1.join(devCacheDir, path_1.basename(entrypoint, '.py'));
3559
- await build_utils_1.download(downloadedFiles, destCache);
3560
- downloadedFiles = await build_utils_1.glob('**', destCache);
3557
+ const { devCacheDir = (0, path_1.join)(workPath, '.now', 'cache') } = meta;
3558
+ const destCache = (0, path_1.join)(devCacheDir, (0, path_1.basename)(entrypoint, '.py'));
3559
+ await (0, build_utils_1.download)(downloadedFiles, destCache);
3560
+ downloadedFiles = await (0, build_utils_1.glob)('**', destCache);
3561
3561
  workPath = destCache;
3562
3562
  }
3563
3563
  return workPath;
3564
3564
  }
3565
3565
  exports.downloadFilesInWorkPath = downloadFilesInWorkPath;
3566
3566
  const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, config, }) => {
3567
- let pythonVersion = version_1.getLatestPythonVersion(meta);
3567
+ let pythonVersion = (0, version_1.getLatestPythonVersion)(meta);
3568
3568
  workPath = await downloadFilesInWorkPath({
3569
3569
  workPath,
3570
3570
  files: originalFiles,
@@ -3580,7 +3580,7 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
3580
3580
  // distutils.errors.DistutilsOptionError: must supply either home
3581
3581
  // or prefix/exec-prefix -- not both
3582
3582
  if (meta.isDev) {
3583
- const setupCfg = path_1.join(workPath, 'setup.cfg');
3583
+ const setupCfg = (0, path_1.join)(workPath, 'setup.cfg');
3584
3584
  await writeFile(setupCfg, '[install]\nprefix=\n');
3585
3585
  }
3586
3586
  }
@@ -3589,7 +3589,7 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
3589
3589
  throw err;
3590
3590
  }
3591
3591
  console.log('Installing required dependencies...');
3592
- await install_1.installRequirement({
3592
+ await (0, install_1.installRequirement)({
3593
3593
  pythonPath: pythonVersion.pythonPath,
3594
3594
  pipPath: pythonVersion.pipPath,
3595
3595
  dependency: 'werkzeug',
@@ -3597,18 +3597,18 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
3597
3597
  workPath,
3598
3598
  meta,
3599
3599
  });
3600
- let fsFiles = await build_utils_1.glob('**', workPath);
3601
- const entryDirectory = path_1.dirname(entrypoint);
3602
- const pipfileLockDir = fsFiles[path_1.join(entryDirectory, 'Pipfile.lock')]
3603
- ? path_1.join(workPath, entryDirectory)
3600
+ let fsFiles = await (0, build_utils_1.glob)('**', workPath);
3601
+ const entryDirectory = (0, path_1.dirname)(entrypoint);
3602
+ const pipfileLockDir = fsFiles[(0, path_1.join)(entryDirectory, 'Pipfile.lock')]
3603
+ ? (0, path_1.join)(workPath, entryDirectory)
3604
3604
  : fsFiles['Pipfile.lock']
3605
3605
  ? workPath
3606
3606
  : null;
3607
3607
  if (pipfileLockDir) {
3608
- build_utils_1.debug('Found "Pipfile.lock"');
3608
+ (0, build_utils_1.debug)('Found "Pipfile.lock"');
3609
3609
  let lock = {};
3610
3610
  try {
3611
- const json = await readFile(path_1.join(pipfileLockDir, 'Pipfile.lock'), 'utf8');
3611
+ const json = await readFile((0, path_1.join)(pipfileLockDir, 'Pipfile.lock'), 'utf8');
3612
3612
  lock = JSON.parse(json);
3613
3613
  }
3614
3614
  catch (err) {
@@ -3617,7 +3617,7 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
3617
3617
  message: 'Unable to parse Pipfile.lock',
3618
3618
  });
3619
3619
  }
3620
- pythonVersion = version_1.getSupportedPythonVersion({
3620
+ pythonVersion = (0, version_1.getSupportedPythonVersion)({
3621
3621
  isDev: meta.isDev,
3622
3622
  pipLockPythonVersion: lock?._meta?.requires?.python_version,
3623
3623
  });
@@ -3625,8 +3625,8 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
3625
3625
  // We use a different`workPath` here because we want `pipfile-requirements` and it's dependencies
3626
3626
  // to not be part of the lambda environment. By using pip's `--target` directive we can isolate
3627
3627
  // it into a separate folder.
3628
- const tempDir = await build_utils_1.getWriteableDirectory();
3629
- await install_1.installRequirement({
3628
+ const tempDir = await (0, build_utils_1.getWriteableDirectory)();
3629
+ await (0, install_1.installRequirement)({
3630
3630
  pythonPath: pythonVersion.pythonPath,
3631
3631
  pipPath: pythonVersion.pipPath,
3632
3632
  dependency: 'pipfile-requirements',
@@ -3638,15 +3638,15 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
3638
3638
  // Python needs to know where to look up all the packages we just installed.
3639
3639
  // We tell it to use the same location as used with `--target`
3640
3640
  process.env.PYTHONPATH = tempDir;
3641
- const convertCmd = path_1.join(tempDir, 'bin', 'pipfile2req');
3641
+ const convertCmd = (0, path_1.join)(tempDir, 'bin', 'pipfile2req');
3642
3642
  await pipenvConvert(convertCmd, pipfileLockDir);
3643
3643
  }
3644
- fsFiles = await build_utils_1.glob('**', workPath);
3645
- const requirementsTxt = path_1.join(entryDirectory, 'requirements.txt');
3644
+ fsFiles = await (0, build_utils_1.glob)('**', workPath);
3645
+ const requirementsTxt = (0, path_1.join)(entryDirectory, 'requirements.txt');
3646
3646
  if (fsFiles[requirementsTxt]) {
3647
- build_utils_1.debug('Found local "requirements.txt"');
3647
+ (0, build_utils_1.debug)('Found local "requirements.txt"');
3648
3648
  const requirementsTxtPath = fsFiles[requirementsTxt].fsPath;
3649
- await install_1.installRequirementsFile({
3649
+ await (0, install_1.installRequirementsFile)({
3650
3650
  pythonPath: pythonVersion.pythonPath,
3651
3651
  pipPath: pythonVersion.pipPath,
3652
3652
  filePath: requirementsTxtPath,
@@ -3655,9 +3655,9 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
3655
3655
  });
3656
3656
  }
3657
3657
  else if (fsFiles['requirements.txt']) {
3658
- build_utils_1.debug('Found global "requirements.txt"');
3658
+ (0, build_utils_1.debug)('Found global "requirements.txt"');
3659
3659
  const requirementsTxtPath = fsFiles['requirements.txt'].fsPath;
3660
- await install_1.installRequirementsFile({
3660
+ await (0, install_1.installRequirementsFile)({
3661
3661
  pythonPath: pythonVersion.pythonPath,
3662
3662
  pipPath: pythonVersion.pipPath,
3663
3663
  filePath: requirementsTxtPath,
@@ -3665,29 +3665,29 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
3665
3665
  meta,
3666
3666
  });
3667
3667
  }
3668
- const originalPyPath = path_1.join(__dirname, '..', 'vc_init.py');
3668
+ const originalPyPath = (0, path_1.join)(__dirname, '..', 'vc_init.py');
3669
3669
  const originalHandlerPyContents = await readFile(originalPyPath, 'utf8');
3670
- build_utils_1.debug('Entrypoint is', entrypoint);
3670
+ (0, build_utils_1.debug)('Entrypoint is', entrypoint);
3671
3671
  const moduleName = entrypoint.replace(/\//g, '.').replace(/\.py$/, '');
3672
3672
  // Since `vercel dev` renames source files, we must reference the original
3673
3673
  const suffix = meta.isDev && !entrypoint.endsWith('.py') ? '.py' : '';
3674
3674
  const entrypointWithSuffix = `${entrypoint}${suffix}`;
3675
- build_utils_1.debug('Entrypoint with suffix is', entrypointWithSuffix);
3675
+ (0, build_utils_1.debug)('Entrypoint with suffix is', entrypointWithSuffix);
3676
3676
  const handlerPyContents = originalHandlerPyContents
3677
3677
  .replace(/__VC_HANDLER_MODULE_NAME/g, moduleName)
3678
3678
  .replace(/__VC_HANDLER_ENTRYPOINT/g, entrypointWithSuffix);
3679
3679
  // in order to allow the user to have `server.py`, we need our `server.py` to be called
3680
3680
  // somethig else
3681
3681
  const handlerPyFilename = 'vc__handler__python';
3682
- await writeFile(path_1.join(workPath, `${handlerPyFilename}.py`), handlerPyContents);
3682
+ await writeFile((0, path_1.join)(workPath, `${handlerPyFilename}.py`), handlerPyContents);
3683
3683
  const globOptions = {
3684
3684
  cwd: workPath,
3685
3685
  ignore: config && typeof config.excludeFiles === 'string'
3686
3686
  ? config.excludeFiles
3687
3687
  : 'node_modules/**',
3688
3688
  };
3689
- const lambda = await build_utils_1.createLambda({
3690
- files: await build_utils_1.glob('**', globOptions),
3689
+ const lambda = await (0, build_utils_1.createLambda)({
3690
+ files: await (0, build_utils_1.glob)('**', globOptions),
3691
3691
  handler: `${handlerPyFilename}.vc_handler`,
3692
3692
  runtime: pythonVersion.runtime,
3693
3693
  environment: {},
@@ -3719,7 +3719,7 @@ print(spec.origin)
3719
3719
  `;
3720
3720
  async function isInstalled(pythonPath, dependency, cwd) {
3721
3721
  try {
3722
- const { stdout } = await execa_1.default(pythonPath, ['-c', makeDependencyCheckCode(dependency)], {
3722
+ const { stdout } = await (0, execa_1.default)(pythonPath, ['-c', makeDependencyCheckCode(dependency)], {
3723
3723
  stdio: 'pipe',
3724
3724
  cwd,
3725
3725
  });
@@ -3738,7 +3738,7 @@ pkg_resources.require(dependencies)
3738
3738
  `;
3739
3739
  async function areRequirementsInstalled(pythonPath, requirementsPath, cwd) {
3740
3740
  try {
3741
- await execa_1.default(pythonPath, ['-c', makeRequirementsCheckCode(requirementsPath)], {
3741
+ await (0, execa_1.default)(pythonPath, ['-c', makeRequirementsCheckCode(requirementsPath)], {
3742
3742
  stdio: 'pipe',
3743
3743
  cwd,
3744
3744
  });
@@ -3766,9 +3766,9 @@ async function pipInstall(pipPath, workPath, args) {
3766
3766
  ...args,
3767
3767
  ];
3768
3768
  const pretty = `${pipPath} ${cmdArgs.join(' ')}`;
3769
- build_utils_1.debug(`Running "${pretty}"...`);
3769
+ (0, build_utils_1.debug)(`Running "${pretty}"...`);
3770
3770
  try {
3771
- await execa_1.default(pipPath, cmdArgs, {
3771
+ await (0, execa_1.default)(pipPath, cmdArgs, {
3772
3772
  cwd: workPath,
3773
3773
  });
3774
3774
  }
@@ -3783,7 +3783,7 @@ async function pipInstall(pipPath, workPath, args) {
3783
3783
  // version of its dependencies
3784
3784
  async function installRequirement({ pythonPath, pipPath, dependency, version, workPath, meta, args = [], }) {
3785
3785
  if (meta.isDev && (await isInstalled(pythonPath, dependency, workPath))) {
3786
- build_utils_1.debug(`Skipping ${dependency} dependency installation, already installed in ${workPath}`);
3786
+ (0, build_utils_1.debug)(`Skipping ${dependency} dependency installation, already installed in ${workPath}`);
3787
3787
  return;
3788
3788
  }
3789
3789
  const exact = `${dependency}==${version}`;
@@ -3797,7 +3797,7 @@ async function installRequirementsFile({ pythonPath, pipPath, filePath, workPath
3797
3797
  // locally, so we'll run a separate installation.
3798
3798
  if (meta.isDev &&
3799
3799
  (await areRequirementsInstalled(pythonPath, filePath, workPath))) {
3800
- build_utils_1.debug(`Skipping requirements file installation, already installed`);
3800
+ (0, build_utils_1.debug)(`Skipping requirements file installation, already installed`);
3801
3801
  return;
3802
3802
  }
3803
3803
  await pipInstall(pipPath, workPath, ['--upgrade', '-r', filePath, ...args]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/python",
3
- "version": "3.1.58",
3
+ "version": "3.1.60",
4
4
  "main": "./dist/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
@@ -17,16 +17,15 @@
17
17
  "build": "node build",
18
18
  "test": "jest --env node --verbose --runInBand --bail",
19
19
  "test-unit": "pnpm test test/unit.test.ts",
20
- "test-e2e": "pnpm test test/integration.test.ts"
20
+ "test-e2e": "pnpm test test/integration-*"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/execa": "^0.9.0",
24
24
  "@types/jest": "27.4.1",
25
25
  "@types/node": "14.18.33",
26
- "@vercel/build-utils": "6.7.1",
26
+ "@vercel/build-utils": "6.7.2",
27
27
  "@vercel/ncc": "0.24.0",
28
- "execa": "^1.0.0",
29
- "typescript": "4.3.4"
28
+ "execa": "^1.0.0"
30
29
  },
31
- "gitHead": "925c8ba18ceec80174d9440cd2cad0e725ed4f56"
30
+ "gitHead": "2de365f9cfea3ce283d2bf855507c71209f1e3d8"
32
31
  }