@vercel/python 2.0.6-canary.1 → 2.0.6-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.
@@ -0,0 +1,9 @@
1
+ import { BuildOptions, shouldServe } from '@vercel/build-utils';
2
+ import { installRequirement, installRequirementsFile } from './install';
3
+ export declare const version = 3;
4
+ export declare function downloadFilesInWorkPath({ entrypoint, workPath, files, meta, }: BuildOptions): Promise<string>;
5
+ export declare const build: ({ workPath, files: originalFiles, entrypoint, meta, config, }: BuildOptions) => Promise<{
6
+ output: import("@vercel/build-utils").Lambda;
7
+ }>;
8
+ export { shouldServe };
9
+ export { installRequirement, installRequirementsFile };
package/dist/index.js CHANGED
@@ -1,10 +1,11 @@
1
+ module.exports =
1
2
  /******/ (() => { // webpackBootstrap
2
3
  /******/ var __webpack_modules__ = ({
3
4
 
4
5
  /***/ 498:
5
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
6
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6
7
 
7
- var once = __nccwpck_require__(197);
8
+ var once = __webpack_require__(197);
8
9
 
9
10
  var noop = function() {};
10
11
 
@@ -103,21 +104,21 @@ module.exports = eos;
103
104
  /***/ }),
104
105
 
105
106
  /***/ 580:
106
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
107
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
107
108
 
108
109
  "use strict";
109
110
 
110
- const path = __nccwpck_require__(622);
111
- const childProcess = __nccwpck_require__(129);
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);
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);
121
122
 
122
123
  const TEN_MEGABYTES = 1000 * 1000 * 10;
123
124
 
@@ -472,13 +473,13 @@ module.exports.shellSync = (cmd, opts) => handleShell(module.exports.sync, cmd,
472
473
  /***/ }),
473
474
 
474
475
  /***/ 529:
475
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
476
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
476
477
 
477
478
  "use strict";
478
479
 
479
480
  // Older verions of Node.js might not have `util.getSystemErrorName()`.
480
481
  // In that case, fall back to a deprecated internal.
481
- const util = __nccwpck_require__(669);
482
+ const util = __webpack_require__(669);
482
483
 
483
484
  let uv;
484
485
 
@@ -568,14 +569,14 @@ module.exports = opts => {
568
569
  /***/ }),
569
570
 
570
571
  /***/ 146:
571
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
572
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
572
573
 
573
574
  "use strict";
574
575
 
575
576
 
576
- const cp = __nccwpck_require__(129);
577
- const parse = __nccwpck_require__(892);
578
- const enoent = __nccwpck_require__(603);
577
+ const cp = __webpack_require__(129);
578
+ const parse = __webpack_require__(892);
579
+ const enoent = __webpack_require__(603);
579
580
 
580
581
  function spawn(command, args, options) {
581
582
  // Parse the arguments
@@ -682,17 +683,17 @@ module.exports = {
682
683
  /***/ }),
683
684
 
684
685
  /***/ 892:
685
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
686
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
686
687
 
687
688
  "use strict";
688
689
 
689
690
 
690
- const path = __nccwpck_require__(622);
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);
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);
696
697
 
697
698
  const isWin = process.platform === 'win32';
698
699
  const isExecutableRegExp = /\.(?:com|exe)$/i;
@@ -868,13 +869,13 @@ module.exports.argument = escapeArgument;
868
869
  /***/ }),
869
870
 
870
871
  /***/ 601:
871
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
872
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
872
873
 
873
874
  "use strict";
874
875
 
875
876
 
876
- const fs = __nccwpck_require__(747);
877
- const shebangCommand = __nccwpck_require__(970);
877
+ const fs = __webpack_require__(747);
878
+ const shebangCommand = __webpack_require__(970);
878
879
 
879
880
  function readShebang(command) {
880
881
  // Read the first 150 bytes from the file
@@ -908,14 +909,14 @@ module.exports = readShebang;
908
909
  /***/ }),
909
910
 
910
911
  /***/ 653:
911
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
912
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
912
913
 
913
914
  "use strict";
914
915
 
915
916
 
916
- const path = __nccwpck_require__(622);
917
- const which = __nccwpck_require__(201);
918
- const pathKey = __nccwpck_require__(258)();
917
+ const path = __webpack_require__(622);
918
+ const which = __webpack_require__(201);
919
+ const pathKey = __webpack_require__(258)();
919
920
 
920
921
  function resolveCommandAttempt(parsed, withoutPathExt) {
921
922
  const cwd = process.cwd();
@@ -2474,11 +2475,11 @@ function coerce (version) {
2474
2475
  /***/ }),
2475
2476
 
2476
2477
  /***/ 114:
2477
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2478
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2478
2479
 
2479
2480
  "use strict";
2480
2481
 
2481
- const {PassThrough} = __nccwpck_require__(413);
2482
+ const {PassThrough} = __webpack_require__(413);
2482
2483
 
2483
2484
  module.exports = options => {
2484
2485
  options = Object.assign({}, options);
@@ -2533,12 +2534,12 @@ module.exports = options => {
2533
2534
  /***/ }),
2534
2535
 
2535
2536
  /***/ 136:
2536
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2537
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2537
2538
 
2538
2539
  "use strict";
2539
2540
 
2540
- const pump = __nccwpck_require__(595);
2541
- const bufferStream = __nccwpck_require__(114);
2541
+ const pump = __webpack_require__(595);
2542
+ const bufferStream = __webpack_require__(114);
2542
2543
 
2543
2544
  class MaxBufferError extends Error {
2544
2545
  constructor() {
@@ -2620,14 +2621,14 @@ isStream.transform = function (stream) {
2620
2621
  /***/ }),
2621
2622
 
2622
2623
  /***/ 228:
2623
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2624
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2624
2625
 
2625
- var fs = __nccwpck_require__(747)
2626
+ var fs = __webpack_require__(747)
2626
2627
  var core
2627
2628
  if (process.platform === 'win32' || global.TESTING_WINDOWS) {
2628
- core = __nccwpck_require__(214)
2629
+ core = __webpack_require__(214)
2629
2630
  } else {
2630
- core = __nccwpck_require__(211)
2631
+ core = __webpack_require__(211)
2631
2632
  }
2632
2633
 
2633
2634
  module.exports = isexe
@@ -2684,12 +2685,12 @@ function sync (path, options) {
2684
2685
  /***/ }),
2685
2686
 
2686
2687
  /***/ 211:
2687
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2688
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2688
2689
 
2689
2690
  module.exports = isexe
2690
2691
  isexe.sync = sync
2691
2692
 
2692
- var fs = __nccwpck_require__(747)
2693
+ var fs = __webpack_require__(747)
2693
2694
 
2694
2695
  function isexe (path, options, cb) {
2695
2696
  fs.stat(path, function (er, stat) {
@@ -2732,12 +2733,12 @@ function checkMode (stat, options) {
2732
2733
  /***/ }),
2733
2734
 
2734
2735
  /***/ 214:
2735
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2736
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2736
2737
 
2737
2738
  module.exports = isexe
2738
2739
  isexe.sync = sync
2739
2740
 
2740
- var fs = __nccwpck_require__(747)
2741
+ var fs = __webpack_require__(747)
2741
2742
 
2742
2743
  function checkPathExt (path, options) {
2743
2744
  var pathext = options.pathExt !== undefined ?
@@ -2800,12 +2801,12 @@ module.exports = function(fn) {
2800
2801
  /***/ }),
2801
2802
 
2802
2803
  /***/ 783:
2803
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2804
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2804
2805
 
2805
2806
  "use strict";
2806
2807
 
2807
- const path = __nccwpck_require__(622);
2808
- const pathKey = __nccwpck_require__(948);
2808
+ const path = __webpack_require__(622);
2809
+ const pathKey = __webpack_require__(948);
2809
2810
 
2810
2811
  module.exports = opts => {
2811
2812
  opts = Object.assign({
@@ -2868,9 +2869,9 @@ module.exports = opts => {
2868
2869
  /***/ }),
2869
2870
 
2870
2871
  /***/ 197:
2871
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2872
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2872
2873
 
2873
- var wrappy = __nccwpck_require__(586)
2874
+ var wrappy = __webpack_require__(586)
2874
2875
  module.exports = wrappy(once)
2875
2876
  module.exports.strict = wrappy(onceStrict)
2876
2877
 
@@ -2940,11 +2941,11 @@ module.exports = (promise, onFinally) => {
2940
2941
  /***/ }),
2941
2942
 
2942
2943
  /***/ 595:
2943
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
2944
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2944
2945
 
2945
- var once = __nccwpck_require__(197)
2946
- var eos = __nccwpck_require__(498)
2947
- var fs = __nccwpck_require__(747) // we only need fs to get the ReadStream and WriteStream prototypes
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
2948
2949
 
2949
2950
  var noop = function () {}
2950
2951
  var ancient = /^v?\.0/.test(process.version)
@@ -3029,11 +3030,11 @@ module.exports = pump
3029
3030
  /***/ }),
3030
3031
 
3031
3032
  /***/ 970:
3032
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
3033
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3033
3034
 
3034
3035
  "use strict";
3035
3036
 
3036
- var shebangRegex = __nccwpck_require__(504);
3037
+ var shebangRegex = __webpack_require__(504);
3037
3038
 
3038
3039
  module.exports = function (str) {
3039
3040
  var match = str.match(shebangRegex);
@@ -3066,16 +3067,16 @@ module.exports = /^#!.*/;
3066
3067
  /***/ }),
3067
3068
 
3068
3069
  /***/ 28:
3069
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
3070
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3070
3071
 
3071
3072
  // Note: since nyc uses this module to output coverage, any lines
3072
3073
  // that are in the direct sync flow of nyc's outputCoverage are
3073
3074
  // ignored, since we can never get coverage for them.
3074
- var assert = __nccwpck_require__(357)
3075
- var signals = __nccwpck_require__(19)
3075
+ var assert = __webpack_require__(357)
3076
+ var signals = __webpack_require__(19)
3076
3077
  var isWin = /^win/i.test(process.platform)
3077
3078
 
3078
- var EE = __nccwpck_require__(614)
3079
+ var EE = __webpack_require__(614)
3079
3080
  /* istanbul ignore if */
3080
3081
  if (typeof EE !== 'function') {
3081
3082
  EE = EE.EventEmitter
@@ -3319,7 +3320,7 @@ module.exports = function (x) {
3319
3320
  /***/ }),
3320
3321
 
3321
3322
  /***/ 201:
3322
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
3323
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3323
3324
 
3324
3325
  module.exports = which
3325
3326
  which.sync = whichSync
@@ -3328,9 +3329,9 @@ var isWindows = process.platform === 'win32' ||
3328
3329
  process.env.OSTYPE === 'cygwin' ||
3329
3330
  process.env.OSTYPE === 'msys'
3330
3331
 
3331
- var path = __nccwpck_require__(622)
3332
+ var path = __webpack_require__(622)
3332
3333
  var COLON = isWindows ? ';' : ':'
3333
- var isexe = __nccwpck_require__(228)
3334
+ var isexe = __webpack_require__(228)
3334
3335
 
3335
3336
  function getNotFoundError (cmd) {
3336
3337
  var er = new Error('not found: ' + cmd)
@@ -3500,291 +3501,55 @@ function wrappy (fn, cb) {
3500
3501
 
3501
3502
  /***/ }),
3502
3503
 
3503
- /***/ 357:
3504
- /***/ ((module) => {
3505
-
3506
- "use strict";
3507
- module.exports = require("assert");
3508
-
3509
- /***/ }),
3510
-
3511
- /***/ 129:
3512
- /***/ ((module) => {
3504
+ /***/ 855:
3505
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
3513
3506
 
3514
3507
  "use strict";
3515
- module.exports = require("child_process");
3516
-
3517
- /***/ }),
3518
-
3519
- /***/ 614:
3520
- /***/ ((module) => {
3521
-
3522
- "use strict";
3523
- module.exports = require("events");
3524
-
3525
- /***/ }),
3526
-
3527
- /***/ 747:
3528
- /***/ ((module) => {
3529
-
3530
- "use strict";
3531
- module.exports = require("fs");
3532
-
3533
- /***/ }),
3534
-
3535
- /***/ 622:
3536
- /***/ ((module) => {
3537
-
3538
- "use strict";
3539
- module.exports = require("path");
3540
-
3541
- /***/ }),
3542
-
3543
- /***/ 413:
3544
- /***/ ((module) => {
3545
-
3546
- "use strict";
3547
- module.exports = require("stream");
3548
-
3549
- /***/ }),
3550
-
3551
- /***/ 669:
3552
- /***/ ((module) => {
3553
-
3554
- "use strict";
3555
- module.exports = require("util");
3556
-
3557
- /***/ })
3558
-
3559
- /******/ });
3560
- /************************************************************************/
3561
- /******/ // The module cache
3562
- /******/ var __webpack_module_cache__ = {};
3563
- /******/
3564
- /******/ // The require function
3565
- /******/ function __nccwpck_require__(moduleId) {
3566
- /******/ // Check if module is in cache
3567
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
3568
- /******/ if (cachedModule !== undefined) {
3569
- /******/ return cachedModule.exports;
3570
- /******/ }
3571
- /******/ // Create a new module (and put it into the cache)
3572
- /******/ var module = __webpack_module_cache__[moduleId] = {
3573
- /******/ // no module.id needed
3574
- /******/ // no module.loaded needed
3575
- /******/ exports: {}
3576
- /******/ };
3577
- /******/
3578
- /******/ // Execute the module function
3579
- /******/ var threw = true;
3580
- /******/ try {
3581
- /******/ __webpack_modules__[moduleId](module, module.exports, __nccwpck_require__);
3582
- /******/ threw = false;
3583
- /******/ } finally {
3584
- /******/ if(threw) delete __webpack_module_cache__[moduleId];
3585
- /******/ }
3586
- /******/
3587
- /******/ // Return the exports of the module
3588
- /******/ return module.exports;
3589
- /******/ }
3590
- /******/
3591
- /************************************************************************/
3592
- /******/ /* webpack/runtime/compat get default export */
3593
- /******/ (() => {
3594
- /******/ // getDefaultExport function for compatibility with non-harmony modules
3595
- /******/ __nccwpck_require__.n = (module) => {
3596
- /******/ var getter = module && module.__esModule ?
3597
- /******/ () => (module['default']) :
3598
- /******/ () => (module);
3599
- /******/ __nccwpck_require__.d(getter, { a: getter });
3600
- /******/ return getter;
3601
- /******/ };
3602
- /******/ })();
3603
- /******/
3604
- /******/ /* webpack/runtime/define property getters */
3605
- /******/ (() => {
3606
- /******/ // define getter functions for harmony exports
3607
- /******/ __nccwpck_require__.d = (exports, definition) => {
3608
- /******/ for(var key in definition) {
3609
- /******/ if(__nccwpck_require__.o(definition, key) && !__nccwpck_require__.o(exports, key)) {
3610
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
3611
- /******/ }
3612
- /******/ }
3613
- /******/ };
3614
- /******/ })();
3615
- /******/
3616
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
3617
- /******/ (() => {
3618
- /******/ __nccwpck_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
3619
- /******/ })();
3620
- /******/
3621
- /******/ /* webpack/runtime/make namespace object */
3622
- /******/ (() => {
3623
- /******/ // define __esModule on exports
3624
- /******/ __nccwpck_require__.r = (exports) => {
3625
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
3626
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3627
- /******/ }
3628
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
3629
- /******/ };
3630
- /******/ })();
3631
- /******/
3632
- /******/ /* webpack/runtime/compat */
3633
- /******/
3634
- /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
3635
- /******/
3636
- /************************************************************************/
3637
- var __webpack_exports__ = {};
3638
- // This entry need to be wrapped in an IIFE because it need to be in strict mode.
3639
- (() => {
3640
- "use strict";
3641
- // ESM COMPAT FLAG
3642
- __nccwpck_require__.r(__webpack_exports__);
3643
-
3644
- // EXPORTS
3645
- __nccwpck_require__.d(__webpack_exports__, {
3646
- "build": () => (/* binding */ build),
3647
- "downloadFilesInWorkPath": () => (/* binding */ downloadFilesInWorkPath),
3648
- "installRequirement": () => (/* reexport */ installRequirement),
3649
- "installRequirementsFile": () => (/* reexport */ installRequirementsFile),
3650
- "shouldServe": () => (/* reexport */ build_utils_namespaceObject.shouldServe),
3651
- "version": () => (/* binding */ version)
3652
- });
3653
-
3654
- // EXTERNAL MODULE: external "path"
3655
- var external_path_ = __nccwpck_require__(622);
3656
- // EXTERNAL MODULE: ../../node_modules/execa/index.js
3657
- var execa = __nccwpck_require__(580);
3658
- var execa_default = /*#__PURE__*/__nccwpck_require__.n(execa);
3659
- // EXTERNAL MODULE: external "fs"
3660
- var external_fs_ = __nccwpck_require__(747);
3661
- var external_fs_default = /*#__PURE__*/__nccwpck_require__.n(external_fs_);
3662
- // EXTERNAL MODULE: external "util"
3663
- var external_util_ = __nccwpck_require__(669);
3664
- ;// CONCATENATED MODULE: external "@vercel/build-utils"
3665
- const build_utils_namespaceObject = require("@vercel/build-utils");
3666
- ;// CONCATENATED MODULE: ./src/install.ts
3667
-
3668
-
3669
- const pipPath = 'pip3';
3670
- const makeDependencyCheckCode = (dependency) => `
3671
- from importlib import util
3672
- dep = '${dependency}'.replace('-', '_')
3673
- spec = util.find_spec(dep)
3674
- print(spec.origin)
3675
- `;
3676
- async function isInstalled(dependency, cwd) {
3677
- try {
3678
- const { stdout } = await execa_default()('python3', ['-c', makeDependencyCheckCode(dependency)], {
3679
- stdio: 'pipe',
3680
- cwd,
3681
- });
3682
- return stdout.startsWith(cwd);
3683
- }
3684
- catch (err) {
3685
- return false;
3686
- }
3687
- }
3688
- const makeRequirementsCheckCode = (requirementsPath) => `
3689
- import distutils.text_file
3690
- import pkg_resources
3691
- from pkg_resources import DistributionNotFound, VersionConflict
3692
- dependencies = distutils.text_file.TextFile(filename='${requirementsPath}').readlines()
3693
- pkg_resources.require(dependencies)
3694
- `;
3695
- async function areRequirementsInstalled(requirementsPath, cwd) {
3696
- try {
3697
- await execa_default()('python3', ['-c', makeRequirementsCheckCode(requirementsPath)], {
3698
- stdio: 'pipe',
3699
- cwd,
3700
- });
3701
- return true;
3702
- }
3703
- catch (err) {
3704
- return false;
3705
- }
3706
- }
3707
- async function pipInstall(workPath, args) {
3708
- const target = '.';
3709
- // See: https://github.com/pypa/pip/issues/4222#issuecomment-417646535
3710
- //
3711
- // Disable installing to the Python user install directory, which is
3712
- // the default behavior on Debian systems and causes error:
3713
- //
3714
- // distutils.errors.DistutilsOptionError: can't combine user with
3715
- // prefix, exec_prefix/home, or install_(plat)base
3716
- process.env.PIP_USER = '0';
3717
- const cmdArgs = [
3718
- 'install',
3719
- '--disable-pip-version-check',
3720
- '--target',
3721
- target,
3722
- ...args,
3723
- ];
3724
- (0,build_utils_namespaceObject.debug)(`Running "pip3 ${cmdArgs.join(' ')}"...`);
3725
- try {
3726
- await execa_default()(pipPath, cmdArgs, {
3727
- cwd: workPath,
3728
- stdio: 'pipe',
3729
- });
3730
- }
3731
- catch (err) {
3732
- console.log(`Failed to run "pip3 ${cmdArgs.join(' ')}"`);
3733
- throw err;
3734
- }
3735
- }
3736
- async function installRequirement({ dependency, version, workPath, meta, args = [], }) {
3737
- if (meta.isDev && (await isInstalled(dependency, workPath))) {
3738
- (0,build_utils_namespaceObject.debug)(`Skipping ${dependency} dependency installation, already installed in ${workPath}`);
3739
- return;
3740
- }
3741
- const exact = `${dependency}==${version}`;
3742
- await pipInstall(workPath, [exact, ...args]);
3743
- }
3744
- async function installRequirementsFile({ filePath, workPath, meta, args = [], }) {
3745
- if (meta.isDev && (await areRequirementsInstalled(filePath, workPath))) {
3746
- (0,build_utils_namespaceObject.debug)(`Skipping requirements file installation, already installed`);
3747
- return;
3748
- }
3749
- await pipInstall(workPath, ['-r', filePath, ...args]);
3750
- }
3751
-
3752
- ;// CONCATENATED MODULE: ./src/index.ts
3753
-
3754
-
3755
-
3756
-
3757
- const readFile = (0,external_util_.promisify)((external_fs_default()).readFile);
3758
- const writeFile = (0,external_util_.promisify)((external_fs_default()).writeFile);
3759
-
3760
3508
 
3509
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3510
+ return (mod && mod.__esModule) ? mod : { "default": mod };
3511
+ };
3512
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
3513
+ 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);
3518
+ const readFile = util_1.promisify(fs_1.default.readFile);
3519
+ const writeFile = util_1.promisify(fs_1.default.writeFile);
3520
+ const build_utils_1 = __webpack_require__(445);
3521
+ Object.defineProperty(exports, "shouldServe", ({ enumerable: true, get: function () { return build_utils_1.shouldServe; } }));
3522
+ const install_1 = __webpack_require__(95);
3523
+ Object.defineProperty(exports, "installRequirement", ({ enumerable: true, get: function () { return install_1.installRequirement; } }));
3524
+ Object.defineProperty(exports, "installRequirementsFile", ({ enumerable: true, get: function () { return install_1.installRequirementsFile; } }));
3761
3525
  async function pipenvConvert(cmd, srcDir) {
3762
- (0,build_utils_namespaceObject.debug)('Running pipfile2req...');
3526
+ build_utils_1.debug('Running pipfile2req...');
3763
3527
  try {
3764
- const out = await execa_default().stdout(cmd, [], {
3528
+ const out = await execa_1.default.stdout(cmd, [], {
3765
3529
  cwd: srcDir,
3766
3530
  });
3767
- external_fs_default().writeFileSync((0,external_path_.join)(srcDir, 'requirements.txt'), out);
3531
+ fs_1.default.writeFileSync(path_1.join(srcDir, 'requirements.txt'), out);
3768
3532
  }
3769
3533
  catch (err) {
3770
3534
  console.log('Failed to run "pipfile2req"');
3771
3535
  throw err;
3772
3536
  }
3773
3537
  }
3774
- const version = 3;
3538
+ exports.version = 3;
3775
3539
  async function downloadFilesInWorkPath({ entrypoint, workPath, files, meta = {}, }) {
3776
- (0,build_utils_namespaceObject.debug)('Downloading user files...');
3777
- let downloadedFiles = await (0,build_utils_namespaceObject.download)(files, workPath, meta);
3540
+ build_utils_1.debug('Downloading user files...');
3541
+ let downloadedFiles = await build_utils_1.download(files, workPath, meta);
3778
3542
  if (meta.isDev) {
3779
3543
  // Old versions of the CLI don't assign this property
3780
- const { devCacheDir = (0,external_path_.join)(workPath, '.now', 'cache') } = meta;
3781
- const destCache = (0,external_path_.join)(devCacheDir, (0,external_path_.basename)(entrypoint, '.py'));
3782
- await (0,build_utils_namespaceObject.download)(downloadedFiles, destCache);
3783
- downloadedFiles = await (0,build_utils_namespaceObject.glob)('**', destCache);
3544
+ const { devCacheDir = path_1.join(workPath, '.now', 'cache') } = meta;
3545
+ const destCache = path_1.join(devCacheDir, path_1.basename(entrypoint, '.py'));
3546
+ await build_utils_1.download(downloadedFiles, destCache);
3547
+ downloadedFiles = await build_utils_1.glob('**', destCache);
3784
3548
  workPath = destCache;
3785
3549
  }
3786
3550
  return workPath;
3787
3551
  }
3552
+ exports.downloadFilesInWorkPath = downloadFilesInWorkPath;
3788
3553
  const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, config, }) => {
3789
3554
  workPath = await downloadFilesInWorkPath({
3790
3555
  workPath,
@@ -3802,7 +3567,7 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
3802
3567
  // distutils.errors.DistutilsOptionError: must supply either home
3803
3568
  // or prefix/exec-prefix -- not both
3804
3569
  if (meta.isDev) {
3805
- const setupCfg = (0,external_path_.join)(workPath, 'setup.cfg');
3570
+ const setupCfg = path_1.join(workPath, 'setup.cfg');
3806
3571
  await writeFile(setupCfg, '[install]\nprefix=\n');
3807
3572
  }
3808
3573
  }
@@ -3811,27 +3576,27 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
3811
3576
  throw err;
3812
3577
  }
3813
3578
  console.log('Installing required dependencies...');
3814
- await installRequirement({
3579
+ await install_1.installRequirement({
3815
3580
  dependency: 'werkzeug',
3816
3581
  version: '1.0.1',
3817
3582
  workPath,
3818
3583
  meta,
3819
3584
  });
3820
- let fsFiles = await (0,build_utils_namespaceObject.glob)('**', workPath);
3821
- const entryDirectory = (0,external_path_.dirname)(entrypoint);
3822
- const pipfileLockDir = fsFiles[(0,external_path_.join)(entryDirectory, 'Pipfile.lock')]
3823
- ? (0,external_path_.join)(workPath, entryDirectory)
3585
+ let fsFiles = await build_utils_1.glob('**', workPath);
3586
+ const entryDirectory = path_1.dirname(entrypoint);
3587
+ const pipfileLockDir = fsFiles[path_1.join(entryDirectory, 'Pipfile.lock')]
3588
+ ? path_1.join(workPath, entryDirectory)
3824
3589
  : fsFiles['Pipfile.lock']
3825
3590
  ? workPath
3826
3591
  : null;
3827
3592
  if (pipfileLockDir) {
3828
- (0,build_utils_namespaceObject.debug)('Found "Pipfile.lock"');
3593
+ build_utils_1.debug('Found "Pipfile.lock"');
3829
3594
  // Convert Pipenv.Lock to requirements.txt.
3830
3595
  // We use a different`workPath` here because we want `pipfile-requirements` and it's dependencies
3831
3596
  // to not be part of the lambda environment. By using pip's `--target` directive we can isolate
3832
3597
  // it into a separate folder.
3833
- const tempDir = await (0,build_utils_namespaceObject.getWriteableDirectory)();
3834
- await installRequirement({
3598
+ const tempDir = await build_utils_1.getWriteableDirectory();
3599
+ await install_1.installRequirement({
3835
3600
  dependency: 'pipfile-requirements',
3836
3601
  version: '0.3.0',
3837
3602
  workPath: tempDir,
@@ -3841,44 +3606,44 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
3841
3606
  // Python needs to know where to look up all the packages we just installed.
3842
3607
  // We tell it to use the same location as used with `--target`
3843
3608
  process.env.PYTHONPATH = tempDir;
3844
- const convertCmd = (0,external_path_.join)(tempDir, 'bin', 'pipfile2req');
3609
+ const convertCmd = path_1.join(tempDir, 'bin', 'pipfile2req');
3845
3610
  await pipenvConvert(convertCmd, pipfileLockDir);
3846
3611
  }
3847
- fsFiles = await (0,build_utils_namespaceObject.glob)('**', workPath);
3848
- const requirementsTxt = (0,external_path_.join)(entryDirectory, 'requirements.txt');
3612
+ fsFiles = await build_utils_1.glob('**', workPath);
3613
+ const requirementsTxt = path_1.join(entryDirectory, 'requirements.txt');
3849
3614
  if (fsFiles[requirementsTxt]) {
3850
- (0,build_utils_namespaceObject.debug)('Found local "requirements.txt"');
3615
+ build_utils_1.debug('Found local "requirements.txt"');
3851
3616
  const requirementsTxtPath = fsFiles[requirementsTxt].fsPath;
3852
- await installRequirementsFile({
3617
+ await install_1.installRequirementsFile({
3853
3618
  filePath: requirementsTxtPath,
3854
3619
  workPath,
3855
3620
  meta,
3856
3621
  });
3857
3622
  }
3858
3623
  else if (fsFiles['requirements.txt']) {
3859
- (0,build_utils_namespaceObject.debug)('Found global "requirements.txt"');
3624
+ build_utils_1.debug('Found global "requirements.txt"');
3860
3625
  const requirementsTxtPath = fsFiles['requirements.txt'].fsPath;
3861
- await installRequirementsFile({
3626
+ await install_1.installRequirementsFile({
3862
3627
  filePath: requirementsTxtPath,
3863
3628
  workPath,
3864
3629
  meta,
3865
3630
  });
3866
3631
  }
3867
- const originalPyPath = __nccwpck_require__.ab + "vc_init.py";
3868
- const originalHandlerPyContents = await readFile(__nccwpck_require__.ab + "vc_init.py", 'utf8');
3869
- (0,build_utils_namespaceObject.debug)('Entrypoint is', entrypoint);
3632
+ const originalPyPath = __webpack_require__.ab + "vc_init.py";
3633
+ const originalHandlerPyContents = await readFile(__webpack_require__.ab + "vc_init.py", 'utf8');
3634
+ build_utils_1.debug('Entrypoint is', entrypoint);
3870
3635
  const moduleName = entrypoint.replace(/\//g, '.').replace(/\.py$/, '');
3871
3636
  // Since `vercel dev` renames source files, we must reference the original
3872
3637
  const suffix = meta.isDev && !entrypoint.endsWith('.py') ? '.py' : '';
3873
3638
  const entrypointWithSuffix = `${entrypoint}${suffix}`;
3874
- (0,build_utils_namespaceObject.debug)('Entrypoint with suffix is', entrypointWithSuffix);
3639
+ build_utils_1.debug('Entrypoint with suffix is', entrypointWithSuffix);
3875
3640
  const handlerPyContents = originalHandlerPyContents
3876
3641
  .replace(/__VC_HANDLER_MODULE_NAME/g, moduleName)
3877
3642
  .replace(/__VC_HANDLER_ENTRYPOINT/g, entrypointWithSuffix);
3878
3643
  // in order to allow the user to have `server.py`, we need our `server.py` to be called
3879
3644
  // somethig else
3880
3645
  const handlerPyFilename = 'vc__handler__python';
3881
- await writeFile((0,external_path_.join)(workPath, `${handlerPyFilename}.py`), handlerPyContents);
3646
+ await writeFile(path_1.join(workPath, `${handlerPyFilename}.py`), handlerPyContents);
3882
3647
  // Use the system-installed version of `python3` when running via `vercel dev`
3883
3648
  const runtime = meta.isDev ? 'python3' : 'python3.6';
3884
3649
  const globOptions = {
@@ -3887,20 +3652,225 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
3887
3652
  ? config.excludeFiles
3888
3653
  : 'node_modules/**',
3889
3654
  };
3890
- const lambda = await (0,build_utils_namespaceObject.createLambda)({
3891
- files: await (0,build_utils_namespaceObject.glob)('**', globOptions),
3655
+ const lambda = await build_utils_1.createLambda({
3656
+ files: await build_utils_1.glob('**', globOptions),
3892
3657
  handler: `${handlerPyFilename}.vc_handler`,
3893
3658
  runtime,
3894
3659
  environment: {},
3895
3660
  });
3896
3661
  return { output: lambda };
3897
3662
  };
3663
+ exports.build = build;
3664
+
3665
+
3666
+ /***/ }),
3667
+
3668
+ /***/ 95:
3669
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
3670
+
3671
+ "use strict";
3672
+
3673
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3674
+ return (mod && mod.__esModule) ? mod : { "default": mod };
3675
+ };
3676
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
3677
+ exports.installRequirementsFile = exports.installRequirement = void 0;
3678
+ const execa_1 = __importDefault(__webpack_require__(580));
3679
+ const build_utils_1 = __webpack_require__(445);
3680
+ const pipPath = 'pip3';
3681
+ const makeDependencyCheckCode = (dependency) => `
3682
+ from importlib import util
3683
+ dep = '${dependency}'.replace('-', '_')
3684
+ spec = util.find_spec(dep)
3685
+ print(spec.origin)
3686
+ `;
3687
+ async function isInstalled(dependency, cwd) {
3688
+ try {
3689
+ const { stdout } = await execa_1.default('python3', ['-c', makeDependencyCheckCode(dependency)], {
3690
+ stdio: 'pipe',
3691
+ cwd,
3692
+ });
3693
+ return stdout.startsWith(cwd);
3694
+ }
3695
+ catch (err) {
3696
+ return false;
3697
+ }
3698
+ }
3699
+ const makeRequirementsCheckCode = (requirementsPath) => `
3700
+ import distutils.text_file
3701
+ import pkg_resources
3702
+ from pkg_resources import DistributionNotFound, VersionConflict
3703
+ dependencies = distutils.text_file.TextFile(filename='${requirementsPath}').readlines()
3704
+ pkg_resources.require(dependencies)
3705
+ `;
3706
+ async function areRequirementsInstalled(requirementsPath, cwd) {
3707
+ try {
3708
+ await execa_1.default('python3', ['-c', makeRequirementsCheckCode(requirementsPath)], {
3709
+ stdio: 'pipe',
3710
+ cwd,
3711
+ });
3712
+ return true;
3713
+ }
3714
+ catch (err) {
3715
+ return false;
3716
+ }
3717
+ }
3718
+ async function pipInstall(workPath, args) {
3719
+ const target = '.';
3720
+ // See: https://github.com/pypa/pip/issues/4222#issuecomment-417646535
3721
+ //
3722
+ // Disable installing to the Python user install directory, which is
3723
+ // the default behavior on Debian systems and causes error:
3724
+ //
3725
+ // distutils.errors.DistutilsOptionError: can't combine user with
3726
+ // prefix, exec_prefix/home, or install_(plat)base
3727
+ process.env.PIP_USER = '0';
3728
+ const cmdArgs = [
3729
+ 'install',
3730
+ '--disable-pip-version-check',
3731
+ '--target',
3732
+ target,
3733
+ ...args,
3734
+ ];
3735
+ build_utils_1.debug(`Running "pip3 ${cmdArgs.join(' ')}"...`);
3736
+ try {
3737
+ await execa_1.default(pipPath, cmdArgs, {
3738
+ cwd: workPath,
3739
+ stdio: 'pipe',
3740
+ });
3741
+ }
3742
+ catch (err) {
3743
+ console.log(`Failed to run "pip3 ${cmdArgs.join(' ')}"`);
3744
+ throw err;
3745
+ }
3746
+ }
3747
+ // note that any internal dependency that vc_init.py requires that's installed
3748
+ // with this function can get overriden by a newer version from requirements.txt,
3749
+ // so vc_init should do runtime version checks to be compatible with any recent
3750
+ // version of its dependencies
3751
+ async function installRequirement({ dependency, version, workPath, meta, args = [], }) {
3752
+ if (meta.isDev && (await isInstalled(dependency, workPath))) {
3753
+ build_utils_1.debug(`Skipping ${dependency} dependency installation, already installed in ${workPath}`);
3754
+ return;
3755
+ }
3756
+ const exact = `${dependency}==${version}`;
3757
+ await pipInstall(workPath, [exact, ...args]);
3758
+ }
3759
+ exports.installRequirement = installRequirement;
3760
+ async function installRequirementsFile({ filePath, workPath, meta, args = [], }) {
3761
+ if (meta.isDev && (await areRequirementsInstalled(filePath, workPath))) {
3762
+ build_utils_1.debug(`Skipping requirements file installation, already installed`);
3763
+ return;
3764
+ }
3765
+ await pipInstall(workPath, ['--upgrade', '-r', filePath, ...args]);
3766
+ }
3767
+ exports.installRequirementsFile = installRequirementsFile;
3768
+
3769
+
3770
+ /***/ }),
3771
+
3772
+ /***/ 445:
3773
+ /***/ ((module) => {
3774
+
3775
+ "use strict";
3776
+ module.exports = require("@vercel/build-utils");
3777
+
3778
+ /***/ }),
3779
+
3780
+ /***/ 357:
3781
+ /***/ ((module) => {
3782
+
3783
+ "use strict";
3784
+ module.exports = require("assert");
3785
+
3786
+ /***/ }),
3787
+
3788
+ /***/ 129:
3789
+ /***/ ((module) => {
3790
+
3791
+ "use strict";
3792
+ module.exports = require("child_process");
3793
+
3794
+ /***/ }),
3795
+
3796
+ /***/ 614:
3797
+ /***/ ((module) => {
3798
+
3799
+ "use strict";
3800
+ module.exports = require("events");
3801
+
3802
+ /***/ }),
3803
+
3804
+ /***/ 747:
3805
+ /***/ ((module) => {
3806
+
3807
+ "use strict";
3808
+ module.exports = require("fs");
3809
+
3810
+ /***/ }),
3811
+
3812
+ /***/ 622:
3813
+ /***/ ((module) => {
3814
+
3815
+ "use strict";
3816
+ module.exports = require("path");
3817
+
3818
+ /***/ }),
3819
+
3820
+ /***/ 413:
3821
+ /***/ ((module) => {
3898
3822
 
3899
- // internal only - expect breaking changes if other packages depend on these exports
3823
+ "use strict";
3824
+ module.exports = require("stream");
3825
+
3826
+ /***/ }),
3827
+
3828
+ /***/ 669:
3829
+ /***/ ((module) => {
3900
3830
 
3831
+ "use strict";
3832
+ module.exports = require("util");
3901
3833
 
3902
- })();
3834
+ /***/ })
3903
3835
 
3904
- module.exports = __webpack_exports__;
3836
+ /******/ });
3837
+ /************************************************************************/
3838
+ /******/ // The module cache
3839
+ /******/ var __webpack_module_cache__ = {};
3840
+ /******/
3841
+ /******/ // The require function
3842
+ /******/ function __webpack_require__(moduleId) {
3843
+ /******/ // Check if module is in cache
3844
+ /******/ if(__webpack_module_cache__[moduleId]) {
3845
+ /******/ return __webpack_module_cache__[moduleId].exports;
3846
+ /******/ }
3847
+ /******/ // Create a new module (and put it into the cache)
3848
+ /******/ var module = __webpack_module_cache__[moduleId] = {
3849
+ /******/ // no module.id needed
3850
+ /******/ // no module.loaded needed
3851
+ /******/ exports: {}
3852
+ /******/ };
3853
+ /******/
3854
+ /******/ // Execute the module function
3855
+ /******/ var threw = true;
3856
+ /******/ try {
3857
+ /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
3858
+ /******/ threw = false;
3859
+ /******/ } finally {
3860
+ /******/ if(threw) delete __webpack_module_cache__[moduleId];
3861
+ /******/ }
3862
+ /******/
3863
+ /******/ // Return the exports of the module
3864
+ /******/ return module.exports;
3865
+ /******/ }
3866
+ /******/
3867
+ /************************************************************************/
3868
+ /******/ /* webpack/runtime/compat */
3869
+ /******/
3870
+ /******/ __webpack_require__.ab = __dirname + "/";/************************************************************************/
3871
+ /******/ // module exports must be returned from runtime so entry inlining is disabled
3872
+ /******/ // startup
3873
+ /******/ // Load entry module and return exports
3874
+ /******/ return __webpack_require__(855);
3905
3875
  /******/ })()
3906
3876
  ;
@@ -0,0 +1,17 @@
1
+ import { Meta } from '@vercel/build-utils';
2
+ interface InstallRequirementArg {
3
+ dependency: string;
4
+ version: string;
5
+ workPath: string;
6
+ meta: Meta;
7
+ args?: string[];
8
+ }
9
+ export declare function installRequirement({ dependency, version, workPath, meta, args, }: InstallRequirementArg): Promise<void>;
10
+ interface InstallRequirementsFileArg {
11
+ filePath: string;
12
+ workPath: string;
13
+ meta: Meta;
14
+ args?: string[];
15
+ }
16
+ export declare function installRequirementsFile({ filePath, workPath, meta, args, }: InstallRequirementsFileArg): Promise<void>;
17
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/python",
3
- "version": "2.0.6-canary.1",
3
+ "version": "2.0.6-canary.5",
4
4
  "main": "./dist/index.js",
5
5
  "license": "MIT",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
@@ -20,9 +20,9 @@
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/execa": "^0.9.0",
23
- "@vercel/ncc": "0.29.2",
23
+ "@vercel/ncc": "0.24.0",
24
24
  "execa": "^1.0.0",
25
25
  "typescript": "4.3.4"
26
26
  },
27
- "gitHead": "0e51884725ac2e3b09830fae0eab2dc50da9b33e"
27
+ "gitHead": "ed1dacd27698f3bb181f32b516af6953655b37e9"
28
28
  }