@vercel/python 3.0.7 → 3.1.2

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 CHANGED
@@ -1,11 +1,10 @@
1
- module.exports =
2
1
  /******/ (() => { // webpackBootstrap
3
2
  /******/ var __webpack_modules__ = ({
4
3
 
5
4
  /***/ 498:
6
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
7
6
 
8
- var once = __webpack_require__(197);
7
+ var once = __nccwpck_require__(197);
9
8
 
10
9
  var noop = function() {};
11
10
 
@@ -104,21 +103,21 @@ module.exports = eos;
104
103
  /***/ }),
105
104
 
106
105
  /***/ 580:
107
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
106
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
108
107
 
109
108
  "use strict";
110
109
 
111
- const path = __webpack_require__(622);
112
- const childProcess = __webpack_require__(129);
113
- const crossSpawn = __webpack_require__(146);
114
- const stripEof = __webpack_require__(605);
115
- const npmRunPath = __webpack_require__(783);
116
- const isStream = __webpack_require__(381);
117
- const _getStream = __webpack_require__(136);
118
- const pFinally = __webpack_require__(324);
119
- const onExit = __webpack_require__(28);
120
- const errname = __webpack_require__(529);
121
- const stdio = __webpack_require__(205);
110
+ const path = __nccwpck_require__(17);
111
+ const childProcess = __nccwpck_require__(81);
112
+ const crossSpawn = __nccwpck_require__(146);
113
+ const stripEof = __nccwpck_require__(605);
114
+ const npmRunPath = __nccwpck_require__(783);
115
+ const isStream = __nccwpck_require__(381);
116
+ const _getStream = __nccwpck_require__(136);
117
+ const pFinally = __nccwpck_require__(324);
118
+ const onExit = __nccwpck_require__(28);
119
+ const errname = __nccwpck_require__(529);
120
+ const stdio = __nccwpck_require__(205);
122
121
 
123
122
  const TEN_MEGABYTES = 1000 * 1000 * 10;
124
123
 
@@ -473,13 +472,13 @@ module.exports.shellSync = (cmd, opts) => handleShell(module.exports.sync, cmd,
473
472
  /***/ }),
474
473
 
475
474
  /***/ 529:
476
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
475
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
477
476
 
478
477
  "use strict";
479
478
 
480
479
  // Older verions of Node.js might not have `util.getSystemErrorName()`.
481
480
  // In that case, fall back to a deprecated internal.
482
- const util = __webpack_require__(669);
481
+ const util = __nccwpck_require__(837);
483
482
 
484
483
  let uv;
485
484
 
@@ -569,14 +568,14 @@ module.exports = opts => {
569
568
  /***/ }),
570
569
 
571
570
  /***/ 146:
572
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
571
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
573
572
 
574
573
  "use strict";
575
574
 
576
575
 
577
- const cp = __webpack_require__(129);
578
- const parse = __webpack_require__(892);
579
- const enoent = __webpack_require__(603);
576
+ const cp = __nccwpck_require__(81);
577
+ const parse = __nccwpck_require__(892);
578
+ const enoent = __nccwpck_require__(603);
580
579
 
581
580
  function spawn(command, args, options) {
582
581
  // Parse the arguments
@@ -683,17 +682,17 @@ module.exports = {
683
682
  /***/ }),
684
683
 
685
684
  /***/ 892:
686
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
685
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
687
686
 
688
687
  "use strict";
689
688
 
690
689
 
691
- const path = __webpack_require__(622);
692
- const niceTry = __webpack_require__(369);
693
- const resolveCommand = __webpack_require__(653);
694
- const escape = __webpack_require__(849);
695
- const readShebang = __webpack_require__(601);
696
- const semver = __webpack_require__(905);
690
+ const path = __nccwpck_require__(17);
691
+ const niceTry = __nccwpck_require__(369);
692
+ const resolveCommand = __nccwpck_require__(653);
693
+ const escape = __nccwpck_require__(849);
694
+ const readShebang = __nccwpck_require__(601);
695
+ const semver = __nccwpck_require__(905);
697
696
 
698
697
  const isWin = process.platform === 'win32';
699
698
  const isExecutableRegExp = /\.(?:com|exe)$/i;
@@ -869,13 +868,13 @@ module.exports.argument = escapeArgument;
869
868
  /***/ }),
870
869
 
871
870
  /***/ 601:
872
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
871
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
873
872
 
874
873
  "use strict";
875
874
 
876
875
 
877
- const fs = __webpack_require__(747);
878
- const shebangCommand = __webpack_require__(970);
876
+ const fs = __nccwpck_require__(147);
877
+ const shebangCommand = __nccwpck_require__(970);
879
878
 
880
879
  function readShebang(command) {
881
880
  // Read the first 150 bytes from the file
@@ -909,14 +908,14 @@ module.exports = readShebang;
909
908
  /***/ }),
910
909
 
911
910
  /***/ 653:
912
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
911
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
913
912
 
914
913
  "use strict";
915
914
 
916
915
 
917
- const path = __webpack_require__(622);
918
- const which = __webpack_require__(201);
919
- const pathKey = __webpack_require__(258)();
916
+ const path = __nccwpck_require__(17);
917
+ const which = __nccwpck_require__(201);
918
+ const pathKey = __nccwpck_require__(258)();
920
919
 
921
920
  function resolveCommandAttempt(parsed, withoutPathExt) {
922
921
  const cwd = process.cwd();
@@ -2475,11 +2474,11 @@ function coerce (version) {
2475
2474
  /***/ }),
2476
2475
 
2477
2476
  /***/ 114:
2478
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2477
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2479
2478
 
2480
2479
  "use strict";
2481
2480
 
2482
- const {PassThrough} = __webpack_require__(413);
2481
+ const {PassThrough} = __nccwpck_require__(781);
2483
2482
 
2484
2483
  module.exports = options => {
2485
2484
  options = Object.assign({}, options);
@@ -2534,12 +2533,12 @@ module.exports = options => {
2534
2533
  /***/ }),
2535
2534
 
2536
2535
  /***/ 136:
2537
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2536
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2538
2537
 
2539
2538
  "use strict";
2540
2539
 
2541
- const pump = __webpack_require__(595);
2542
- const bufferStream = __webpack_require__(114);
2540
+ const pump = __nccwpck_require__(595);
2541
+ const bufferStream = __nccwpck_require__(114);
2543
2542
 
2544
2543
  class MaxBufferError extends Error {
2545
2544
  constructor() {
@@ -2621,14 +2620,14 @@ isStream.transform = function (stream) {
2621
2620
  /***/ }),
2622
2621
 
2623
2622
  /***/ 228:
2624
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2623
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2625
2624
 
2626
- var fs = __webpack_require__(747)
2625
+ var fs = __nccwpck_require__(147)
2627
2626
  var core
2628
2627
  if (process.platform === 'win32' || global.TESTING_WINDOWS) {
2629
- core = __webpack_require__(214)
2628
+ core = __nccwpck_require__(214)
2630
2629
  } else {
2631
- core = __webpack_require__(211)
2630
+ core = __nccwpck_require__(211)
2632
2631
  }
2633
2632
 
2634
2633
  module.exports = isexe
@@ -2685,12 +2684,12 @@ function sync (path, options) {
2685
2684
  /***/ }),
2686
2685
 
2687
2686
  /***/ 211:
2688
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2687
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2689
2688
 
2690
2689
  module.exports = isexe
2691
2690
  isexe.sync = sync
2692
2691
 
2693
- var fs = __webpack_require__(747)
2692
+ var fs = __nccwpck_require__(147)
2694
2693
 
2695
2694
  function isexe (path, options, cb) {
2696
2695
  fs.stat(path, function (er, stat) {
@@ -2733,12 +2732,12 @@ function checkMode (stat, options) {
2733
2732
  /***/ }),
2734
2733
 
2735
2734
  /***/ 214:
2736
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2735
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2737
2736
 
2738
2737
  module.exports = isexe
2739
2738
  isexe.sync = sync
2740
2739
 
2741
- var fs = __webpack_require__(747)
2740
+ var fs = __nccwpck_require__(147)
2742
2741
 
2743
2742
  function checkPathExt (path, options) {
2744
2743
  var pathext = options.pathExt !== undefined ?
@@ -2801,12 +2800,12 @@ module.exports = function(fn) {
2801
2800
  /***/ }),
2802
2801
 
2803
2802
  /***/ 783:
2804
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2803
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2805
2804
 
2806
2805
  "use strict";
2807
2806
 
2808
- const path = __webpack_require__(622);
2809
- const pathKey = __webpack_require__(948);
2807
+ const path = __nccwpck_require__(17);
2808
+ const pathKey = __nccwpck_require__(948);
2810
2809
 
2811
2810
  module.exports = opts => {
2812
2811
  opts = Object.assign({
@@ -2869,9 +2868,9 @@ module.exports = opts => {
2869
2868
  /***/ }),
2870
2869
 
2871
2870
  /***/ 197:
2872
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2871
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2873
2872
 
2874
- var wrappy = __webpack_require__(586)
2873
+ var wrappy = __nccwpck_require__(586)
2875
2874
  module.exports = wrappy(once)
2876
2875
  module.exports.strict = wrappy(onceStrict)
2877
2876
 
@@ -2941,11 +2940,11 @@ module.exports = (promise, onFinally) => {
2941
2940
  /***/ }),
2942
2941
 
2943
2942
  /***/ 595:
2944
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2943
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2945
2944
 
2946
- var once = __webpack_require__(197)
2947
- var eos = __webpack_require__(498)
2948
- var fs = __webpack_require__(747) // we only need fs to get the ReadStream and WriteStream prototypes
2945
+ var once = __nccwpck_require__(197)
2946
+ var eos = __nccwpck_require__(498)
2947
+ var fs = __nccwpck_require__(147) // we only need fs to get the ReadStream and WriteStream prototypes
2949
2948
 
2950
2949
  var noop = function () {}
2951
2950
  var ancient = /^v?\.0/.test(process.version)
@@ -3030,11 +3029,11 @@ module.exports = pump
3030
3029
  /***/ }),
3031
3030
 
3032
3031
  /***/ 970:
3033
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3032
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
3034
3033
 
3035
3034
  "use strict";
3036
3035
 
3037
- var shebangRegex = __webpack_require__(504);
3036
+ var shebangRegex = __nccwpck_require__(504);
3038
3037
 
3039
3038
  module.exports = function (str) {
3040
3039
  var match = str.match(shebangRegex);
@@ -3067,16 +3066,16 @@ module.exports = /^#!.*/;
3067
3066
  /***/ }),
3068
3067
 
3069
3068
  /***/ 28:
3070
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3069
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
3071
3070
 
3072
3071
  // Note: since nyc uses this module to output coverage, any lines
3073
3072
  // that are in the direct sync flow of nyc's outputCoverage are
3074
3073
  // ignored, since we can never get coverage for them.
3075
- var assert = __webpack_require__(357)
3076
- var signals = __webpack_require__(19)
3074
+ var assert = __nccwpck_require__(491)
3075
+ var signals = __nccwpck_require__(19)
3077
3076
  var isWin = /^win/i.test(process.platform)
3078
3077
 
3079
- var EE = __webpack_require__(614)
3078
+ var EE = __nccwpck_require__(361)
3080
3079
  /* istanbul ignore if */
3081
3080
  if (typeof EE !== 'function') {
3082
3081
  EE = EE.EventEmitter
@@ -3320,7 +3319,7 @@ module.exports = function (x) {
3320
3319
  /***/ }),
3321
3320
 
3322
3321
  /***/ 201:
3323
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3322
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
3324
3323
 
3325
3324
  module.exports = which
3326
3325
  which.sync = whichSync
@@ -3329,9 +3328,9 @@ var isWindows = process.platform === 'win32' ||
3329
3328
  process.env.OSTYPE === 'cygwin' ||
3330
3329
  process.env.OSTYPE === 'msys'
3331
3330
 
3332
- var path = __webpack_require__(622)
3331
+ var path = __nccwpck_require__(17)
3333
3332
  var COLON = isWindows ? ';' : ':'
3334
- var isexe = __webpack_require__(228)
3333
+ var isexe = __nccwpck_require__(228)
3335
3334
 
3336
3335
  function getNotFoundError (cmd) {
3337
3336
  var er = new Error('not found: ' + cmd)
@@ -3502,7 +3501,7 @@ function wrappy (fn, cb) {
3502
3501
  /***/ }),
3503
3502
 
3504
3503
  /***/ 855:
3505
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
3504
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
3506
3505
 
3507
3506
  "use strict";
3508
3507
 
@@ -3511,18 +3510,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3511
3510
  };
3512
3511
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3513
3512
  exports.installRequirementsFile = exports.installRequirement = exports.shouldServe = exports.build = exports.downloadFilesInWorkPath = exports.version = void 0;
3514
- const path_1 = __webpack_require__(622);
3515
- const execa_1 = __importDefault(__webpack_require__(580));
3516
- const fs_1 = __importDefault(__webpack_require__(747));
3517
- const util_1 = __webpack_require__(669);
3513
+ const path_1 = __nccwpck_require__(17);
3514
+ const execa_1 = __importDefault(__nccwpck_require__(580));
3515
+ const fs_1 = __importDefault(__nccwpck_require__(147));
3516
+ const util_1 = __nccwpck_require__(837);
3518
3517
  const readFile = util_1.promisify(fs_1.default.readFile);
3519
3518
  const writeFile = util_1.promisify(fs_1.default.writeFile);
3520
- const build_utils_1 = __webpack_require__(445);
3519
+ const build_utils_1 = __nccwpck_require__(874);
3521
3520
  Object.defineProperty(exports, "shouldServe", ({ enumerable: true, get: function () { return build_utils_1.shouldServe; } }));
3522
- const install_1 = __webpack_require__(95);
3521
+ const install_1 = __nccwpck_require__(95);
3523
3522
  Object.defineProperty(exports, "installRequirement", ({ enumerable: true, get: function () { return install_1.installRequirement; } }));
3524
3523
  Object.defineProperty(exports, "installRequirementsFile", ({ enumerable: true, get: function () { return install_1.installRequirementsFile; } }));
3525
- const version_1 = __webpack_require__(255);
3524
+ const version_1 = __nccwpck_require__(255);
3526
3525
  async function pipenvConvert(cmd, srcDir) {
3527
3526
  build_utils_1.debug('Running pipfile2req...');
3528
3527
  try {
@@ -3653,8 +3652,8 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
3653
3652
  meta,
3654
3653
  });
3655
3654
  }
3656
- const originalPyPath = path_1.join(__dirname, '..', 'vc_init.py');
3657
- const originalHandlerPyContents = await readFile(originalPyPath, 'utf8');
3655
+ const originalPyPath = __nccwpck_require__.ab + "vc_init.py";
3656
+ const originalHandlerPyContents = await readFile(__nccwpck_require__.ab + "vc_init.py", 'utf8');
3658
3657
  build_utils_1.debug('Entrypoint is', entrypoint);
3659
3658
  const moduleName = entrypoint.replace(/\//g, '.').replace(/\.py$/, '');
3660
3659
  // Since `vercel dev` renames source files, we must reference the original
@@ -3688,7 +3687,7 @@ exports.build = build;
3688
3687
  /***/ }),
3689
3688
 
3690
3689
  /***/ 95:
3691
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
3690
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
3692
3691
 
3693
3692
  "use strict";
3694
3693
 
@@ -3697,8 +3696,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3697
3696
  };
3698
3697
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3699
3698
  exports.installRequirementsFile = exports.installRequirement = void 0;
3700
- const execa_1 = __importDefault(__webpack_require__(580));
3701
- const build_utils_1 = __webpack_require__(445);
3699
+ const execa_1 = __importDefault(__nccwpck_require__(580));
3700
+ const build_utils_1 = __nccwpck_require__(874);
3702
3701
  const makeDependencyCheckCode = (dependency) => `
3703
3702
  from importlib import util
3704
3703
  dep = '${dependency}'.replace('-', '_')
@@ -3796,13 +3795,13 @@ exports.installRequirementsFile = installRequirementsFile;
3796
3795
  /***/ }),
3797
3796
 
3798
3797
  /***/ 255:
3799
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3798
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
3800
3799
 
3801
3800
  "use strict";
3802
3801
 
3803
3802
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3804
3803
  exports.getSupportedPythonVersion = exports.getLatestPythonVersion = void 0;
3805
- const build_utils_1 = __webpack_require__(445);
3804
+ const build_utils_1 = __nccwpck_require__(874);
3806
3805
  // The order must be most recent first
3807
3806
  const allOptions = [
3808
3807
  {
@@ -3871,7 +3870,7 @@ function isDiscontinued({ discontinueDate }) {
3871
3870
 
3872
3871
  /***/ }),
3873
3872
 
3874
- /***/ 445:
3873
+ /***/ 874:
3875
3874
  /***/ ((module) => {
3876
3875
 
3877
3876
  "use strict";
@@ -3879,7 +3878,7 @@ module.exports = require("@vercel/build-utils");
3879
3878
 
3880
3879
  /***/ }),
3881
3880
 
3882
- /***/ 357:
3881
+ /***/ 491:
3883
3882
  /***/ ((module) => {
3884
3883
 
3885
3884
  "use strict";
@@ -3887,7 +3886,7 @@ module.exports = require("assert");
3887
3886
 
3888
3887
  /***/ }),
3889
3888
 
3890
- /***/ 129:
3889
+ /***/ 81:
3891
3890
  /***/ ((module) => {
3892
3891
 
3893
3892
  "use strict";
@@ -3895,7 +3894,7 @@ module.exports = require("child_process");
3895
3894
 
3896
3895
  /***/ }),
3897
3896
 
3898
- /***/ 614:
3897
+ /***/ 361:
3899
3898
  /***/ ((module) => {
3900
3899
 
3901
3900
  "use strict";
@@ -3903,7 +3902,7 @@ module.exports = require("events");
3903
3902
 
3904
3903
  /***/ }),
3905
3904
 
3906
- /***/ 747:
3905
+ /***/ 147:
3907
3906
  /***/ ((module) => {
3908
3907
 
3909
3908
  "use strict";
@@ -3911,7 +3910,7 @@ module.exports = require("fs");
3911
3910
 
3912
3911
  /***/ }),
3913
3912
 
3914
- /***/ 622:
3913
+ /***/ 17:
3915
3914
  /***/ ((module) => {
3916
3915
 
3917
3916
  "use strict";
@@ -3919,7 +3918,7 @@ module.exports = require("path");
3919
3918
 
3920
3919
  /***/ }),
3921
3920
 
3922
- /***/ 413:
3921
+ /***/ 781:
3923
3922
  /***/ ((module) => {
3924
3923
 
3925
3924
  "use strict";
@@ -3927,7 +3926,7 @@ module.exports = require("stream");
3927
3926
 
3928
3927
  /***/ }),
3929
3928
 
3930
- /***/ 669:
3929
+ /***/ 837:
3931
3930
  /***/ ((module) => {
3932
3931
 
3933
3932
  "use strict";
@@ -3941,10 +3940,11 @@ module.exports = require("util");
3941
3940
  /******/ var __webpack_module_cache__ = {};
3942
3941
  /******/
3943
3942
  /******/ // The require function
3944
- /******/ function __webpack_require__(moduleId) {
3943
+ /******/ function __nccwpck_require__(moduleId) {
3945
3944
  /******/ // Check if module is in cache
3946
- /******/ if(__webpack_module_cache__[moduleId]) {
3947
- /******/ return __webpack_module_cache__[moduleId].exports;
3945
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
3946
+ /******/ if (cachedModule !== undefined) {
3947
+ /******/ return cachedModule.exports;
3948
3948
  /******/ }
3949
3949
  /******/ // Create a new module (and put it into the cache)
3950
3950
  /******/ var module = __webpack_module_cache__[moduleId] = {
@@ -3956,7 +3956,7 @@ module.exports = require("util");
3956
3956
  /******/ // Execute the module function
3957
3957
  /******/ var threw = true;
3958
3958
  /******/ try {
3959
- /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
3959
+ /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __nccwpck_require__);
3960
3960
  /******/ threw = false;
3961
3961
  /******/ } finally {
3962
3962
  /******/ if(threw) delete __webpack_module_cache__[moduleId];
@@ -3969,10 +3969,15 @@ module.exports = require("util");
3969
3969
  /************************************************************************/
3970
3970
  /******/ /* webpack/runtime/compat */
3971
3971
  /******/
3972
- /******/ __webpack_require__.ab = __dirname + "/";/************************************************************************/
3973
- /******/ // module exports must be returned from runtime so entry inlining is disabled
3972
+ /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
3973
+ /******/
3974
+ /************************************************************************/
3975
+ /******/
3974
3976
  /******/ // startup
3975
3977
  /******/ // Load entry module and return exports
3976
- /******/ return __webpack_require__(855);
3978
+ /******/ // This entry module is referenced by other modules so it can't be inlined
3979
+ /******/ var __webpack_exports__ = __nccwpck_require__(855);
3980
+ /******/ module.exports = __webpack_exports__;
3981
+ /******/
3977
3982
  /******/ })()
3978
3983
  ;
@@ -0,0 +1,299 @@
1
+ import sys
2
+ import base64
3
+ import json
4
+ import inspect
5
+ from importlib import util
6
+ from http.server import BaseHTTPRequestHandler
7
+
8
+ # Import relative path https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
9
+ __vc_spec = util.spec_from_file_location("__VC_HANDLER_MODULE_NAME", "./__VC_HANDLER_ENTRYPOINT")
10
+ __vc_module = util.module_from_spec(__vc_spec)
11
+ sys.modules["__VC_HANDLER_MODULE_NAME"] = __vc_module
12
+ __vc_spec.loader.exec_module(__vc_module)
13
+ __vc_variables = dir(__vc_module)
14
+
15
+
16
+ def format_headers(headers, decode=False):
17
+ keyToList = {}
18
+ for key, value in headers.items():
19
+ if decode and 'decode' in dir(key) and 'decode' in dir(value):
20
+ key = key.decode()
21
+ value = value.decode()
22
+ if key not in keyToList:
23
+ keyToList[key] = []
24
+ keyToList[key].append(value)
25
+ return keyToList
26
+
27
+
28
+ if 'handler' in __vc_variables or 'Handler' in __vc_variables:
29
+ base = __vc_module.handler if ('handler' in __vc_variables) else __vc_module.Handler
30
+ if not issubclass(base, BaseHTTPRequestHandler):
31
+ print('Handler must inherit from BaseHTTPRequestHandler')
32
+ print('See the docs https://vercel.com/docs/runtimes#advanced-usage/advanced-python-usage')
33
+ exit(1)
34
+
35
+ print('using HTTP Handler')
36
+ from http.server import HTTPServer
37
+ import http
38
+ import _thread
39
+
40
+ server = HTTPServer(('', 0), base)
41
+ port = server.server_address[1]
42
+
43
+ def vc_handler(event, context):
44
+ _thread.start_new_thread(server.handle_request, ())
45
+
46
+ payload = json.loads(event['body'])
47
+ path = payload['path']
48
+ headers = payload['headers']
49
+ method = payload['method']
50
+ encoding = payload.get('encoding')
51
+ body = payload.get('body')
52
+
53
+ if (
54
+ (body is not None and len(body) > 0) and
55
+ (encoding is not None and encoding == 'base64')
56
+ ):
57
+ body = base64.b64decode(body)
58
+
59
+ request_body = body.encode('utf-8') if isinstance(body, str) else body
60
+ conn = http.client.HTTPConnection('0.0.0.0', port)
61
+ conn.request(method, path, headers=headers, body=request_body)
62
+ res = conn.getresponse()
63
+
64
+ return_dict = {
65
+ 'statusCode': res.status,
66
+ 'headers': format_headers(res.headers),
67
+ }
68
+
69
+ data = res.read()
70
+
71
+ try:
72
+ return_dict['body'] = data.decode('utf-8')
73
+ except UnicodeDecodeError:
74
+ return_dict['body'] = base64.b64encode(data).decode('utf-8')
75
+ return_dict['encoding'] = 'base64'
76
+
77
+ return return_dict
78
+
79
+ elif 'app' in __vc_variables:
80
+ if (
81
+ not inspect.iscoroutinefunction(__vc_module.app) and
82
+ not inspect.iscoroutinefunction(__vc_module.app.__call__)
83
+ ):
84
+ print('using Web Server Gateway Interface (WSGI)')
85
+ from io import BytesIO
86
+ from urllib.parse import urlparse
87
+ from werkzeug.datastructures import Headers
88
+ from werkzeug.wrappers import Response
89
+
90
+ string_types = (str,)
91
+
92
+ def to_bytes(x, charset=sys.getdefaultencoding(), errors="strict"):
93
+ if x is None:
94
+ return None
95
+ if isinstance(x, (bytes, bytearray, memoryview)):
96
+ return bytes(x)
97
+ if isinstance(x, str):
98
+ return x.encode(charset, errors)
99
+ raise TypeError("Expected bytes")
100
+
101
+ def wsgi_encoding_dance(s, charset="utf-8", errors="replace"):
102
+ if isinstance(s, str):
103
+ s = s.encode(charset)
104
+ return s.decode("latin1", errors)
105
+
106
+ def vc_handler(event, context):
107
+ payload = json.loads(event['body'])
108
+
109
+ headers = Headers(payload.get('headers', {}))
110
+
111
+ body = payload.get('body', '')
112
+ if body != '':
113
+ if payload.get('encoding') == 'base64':
114
+ body = base64.b64decode(body)
115
+ if isinstance(body, string_types):
116
+ body = to_bytes(body, charset='utf-8')
117
+
118
+ url = urlparse(payload['path'])
119
+ query = url.query
120
+ path = url.path
121
+
122
+ environ = {
123
+ 'CONTENT_LENGTH': str(len(body)),
124
+ 'CONTENT_TYPE': headers.get('content-type', ''),
125
+ 'PATH_INFO': path,
126
+ 'QUERY_STRING': query,
127
+ 'REMOTE_ADDR': headers.get(
128
+ 'x-forwarded-for', headers.get(
129
+ 'x-real-ip', payload.get(
130
+ 'true-client-ip', ''))),
131
+ 'REQUEST_METHOD': payload['method'],
132
+ 'SERVER_NAME': headers.get('host', 'lambda'),
133
+ 'SERVER_PORT': headers.get('x-forwarded-port', '80'),
134
+ 'SERVER_PROTOCOL': 'HTTP/1.1',
135
+ 'event': event,
136
+ 'context': context,
137
+ 'wsgi.errors': sys.stderr,
138
+ 'wsgi.input': BytesIO(body),
139
+ 'wsgi.multiprocess': False,
140
+ 'wsgi.multithread': False,
141
+ 'wsgi.run_once': False,
142
+ 'wsgi.url_scheme': headers.get('x-forwarded-proto', 'http'),
143
+ 'wsgi.version': (1, 0),
144
+ }
145
+
146
+ for key, value in environ.items():
147
+ if isinstance(value, string_types):
148
+ environ[key] = wsgi_encoding_dance(value)
149
+
150
+ for key, value in headers.items():
151
+ key = 'HTTP_' + key.upper().replace('-', '_')
152
+ if key not in ('HTTP_CONTENT_TYPE', 'HTTP_CONTENT_LENGTH'):
153
+ environ[key] = value
154
+
155
+ response = Response.from_app(__vc_module.app, environ)
156
+
157
+ return_dict = {
158
+ 'statusCode': response.status_code,
159
+ 'headers': format_headers(response.headers)
160
+ }
161
+
162
+ if response.data:
163
+ return_dict['body'] = base64.b64encode(response.data).decode('utf-8')
164
+ return_dict['encoding'] = 'base64'
165
+
166
+ return return_dict
167
+ else:
168
+ print('using Asynchronous Server Gateway Interface (ASGI)')
169
+ # Originally authored by Jordan Eremieff and included under MIT license:
170
+ # https://github.com/erm/mangum/blob/b4d21c8f5e304a3e17b88bc9fa345106acc50ad7/mangum/__init__.py
171
+ # https://github.com/erm/mangum/blob/b4d21c8f5e304a3e17b88bc9fa345106acc50ad7/LICENSE
172
+ import asyncio
173
+ import enum
174
+ from urllib.parse import urlparse
175
+ from werkzeug.datastructures import Headers
176
+
177
+
178
+ class ASGICycleState(enum.Enum):
179
+ REQUEST = enum.auto()
180
+ RESPONSE = enum.auto()
181
+
182
+
183
+ class ASGICycle:
184
+ def __init__(self, scope):
185
+ self.scope = scope
186
+ self.body = b''
187
+ self.state = ASGICycleState.REQUEST
188
+ self.app_queue = None
189
+ self.response = {}
190
+
191
+ def __call__(self, app, body):
192
+ """
193
+ Receives the application and any body included in the request, then builds the
194
+ ASGI instance using the connection scope.
195
+ Runs until the response is completely read from the application.
196
+ """
197
+ loop = asyncio.new_event_loop()
198
+ self.app_queue = asyncio.Queue(loop=loop)
199
+ self.put_message({'type': 'http.request', 'body': body, 'more_body': False})
200
+
201
+ asgi_instance = app(self.scope, self.receive, self.send)
202
+
203
+ asgi_task = loop.create_task(asgi_instance)
204
+ loop.run_until_complete(asgi_task)
205
+ return self.response
206
+
207
+ def put_message(self, message):
208
+ self.app_queue.put_nowait(message)
209
+
210
+ async def receive(self):
211
+ """
212
+ Awaited by the application to receive messages in the queue.
213
+ """
214
+ message = await self.app_queue.get()
215
+ return message
216
+
217
+ async def send(self, message):
218
+ """
219
+ Awaited by the application to send messages to the current cycle instance.
220
+ """
221
+ message_type = message['type']
222
+
223
+ if self.state is ASGICycleState.REQUEST:
224
+ if message_type != 'http.response.start':
225
+ raise RuntimeError(
226
+ f"Expected 'http.response.start', received: {message_type}"
227
+ )
228
+
229
+ status_code = message['status']
230
+ headers = Headers(message.get('headers', []))
231
+
232
+ self.on_request(headers, status_code)
233
+ self.state = ASGICycleState.RESPONSE
234
+
235
+ elif self.state is ASGICycleState.RESPONSE:
236
+ if message_type != 'http.response.body':
237
+ raise RuntimeError(
238
+ f"Expected 'http.response.body', received: {message_type}"
239
+ )
240
+
241
+ body = message.get('body', b'')
242
+ more_body = message.get('more_body', False)
243
+
244
+ # The body must be completely read before returning the response.
245
+ self.body += body
246
+
247
+ if not more_body:
248
+ self.on_response()
249
+ self.put_message({'type': 'http.disconnect'})
250
+
251
+ def on_request(self, headers, status_code):
252
+ self.response['statusCode'] = status_code
253
+ self.response['headers'] = format_headers(headers, decode=True)
254
+
255
+ def on_response(self):
256
+ if self.body:
257
+ self.response['body'] = base64.b64encode(self.body).decode('utf-8')
258
+ self.response['encoding'] = 'base64'
259
+
260
+ def vc_handler(event, context):
261
+ payload = json.loads(event['body'])
262
+
263
+ headers = payload.get('headers', {})
264
+
265
+ body = payload.get('body', b'')
266
+ if payload.get('encoding') == 'base64':
267
+ body = base64.b64decode(body)
268
+ elif not isinstance(body, bytes):
269
+ body = body.encode()
270
+
271
+ url = urlparse(payload['path'])
272
+ query = url.query.encode()
273
+ path = url.path
274
+
275
+ scope = {
276
+ 'server': (headers.get('host', 'lambda'), headers.get('x-forwarded-port', 80)),
277
+ 'client': (headers.get(
278
+ 'x-forwarded-for', headers.get(
279
+ 'x-real-ip', payload.get(
280
+ 'true-client-ip', ''))), 0),
281
+ 'scheme': headers.get('x-forwarded-proto', 'http'),
282
+ 'root_path': '',
283
+ 'query_string': query,
284
+ 'headers': [[k.lower().encode(), v.encode()] for k, v in headers.items()],
285
+ 'type': 'http',
286
+ 'http_version': '1.1',
287
+ 'method': payload['method'],
288
+ 'path': path,
289
+ 'raw_path': path.encode(),
290
+ }
291
+
292
+ asgi_cycle = ASGICycle(scope)
293
+ response = asgi_cycle(__vc_module.app, body)
294
+ return response
295
+
296
+ else:
297
+ print('Missing variable `handler` or `app` in file "__VC_HANDLER_ENTRYPOINT".')
298
+ print('See the docs https://vercel.com/docs/runtimes#advanced-usage/advanced-python-usage')
299
+ exit(1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/python",
3
- "version": "3.0.7",
3
+ "version": "3.1.2",
4
4
  "main": "./dist/index.js",
5
5
  "license": "MIT",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
@@ -23,10 +23,10 @@
23
23
  "devDependencies": {
24
24
  "@types/execa": "^0.9.0",
25
25
  "@types/jest": "27.4.1",
26
- "@vercel/build-utils": "5.0.3",
27
- "@vercel/ncc": "0.24.0",
26
+ "@vercel/build-utils": "5.0.6",
27
+ "@vercel/ncc": "0.34.0",
28
28
  "execa": "^1.0.0",
29
29
  "typescript": "4.3.4"
30
30
  },
31
- "gitHead": "bef1aec76609ae661f084dcc391edd66f891f0b4"
31
+ "gitHead": "90c18959498cfa852bc56adffcdd16a8bbcbcce6"
32
32
  }