@vercel/python 2.0.6-canary.3 → 2.0.6-canary.7

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)
@@ -3501,7 +3502,7 @@ function wrappy (fn, cb) {
3501
3502
  /***/ }),
3502
3503
 
3503
3504
  /***/ 855:
3504
- /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
3505
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
3505
3506
 
3506
3507
  "use strict";
3507
3508
 
@@ -3510,15 +3511,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3510
3511
  };
3511
3512
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3512
3513
  exports.installRequirementsFile = exports.installRequirement = exports.shouldServe = exports.build = exports.downloadFilesInWorkPath = exports.version = void 0;
3513
- const path_1 = __nccwpck_require__(622);
3514
- const execa_1 = __importDefault(__nccwpck_require__(580));
3515
- const fs_1 = __importDefault(__nccwpck_require__(747));
3516
- const util_1 = __nccwpck_require__(669);
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);
3517
3518
  const readFile = util_1.promisify(fs_1.default.readFile);
3518
3519
  const writeFile = util_1.promisify(fs_1.default.writeFile);
3519
- const build_utils_1 = __nccwpck_require__(445);
3520
+ const build_utils_1 = __webpack_require__(445);
3520
3521
  Object.defineProperty(exports, "shouldServe", ({ enumerable: true, get: function () { return build_utils_1.shouldServe; } }));
3521
- const install_1 = __nccwpck_require__(95);
3522
+ const install_1 = __webpack_require__(95);
3522
3523
  Object.defineProperty(exports, "installRequirement", ({ enumerable: true, get: function () { return install_1.installRequirement; } }));
3523
3524
  Object.defineProperty(exports, "installRequirementsFile", ({ enumerable: true, get: function () { return install_1.installRequirementsFile; } }));
3524
3525
  async function pipenvConvert(cmd, srcDir) {
@@ -3527,6 +3528,7 @@ async function pipenvConvert(cmd, srcDir) {
3527
3528
  const out = await execa_1.default.stdout(cmd, [], {
3528
3529
  cwd: srcDir,
3529
3530
  });
3531
+ build_utils_1.debug('Contents of requirements.txt is: ' + out);
3530
3532
  fs_1.default.writeFileSync(path_1.join(srcDir, 'requirements.txt'), out);
3531
3533
  }
3532
3534
  catch (err) {
@@ -3550,6 +3552,10 @@ async function downloadFilesInWorkPath({ entrypoint, workPath, files, meta = {},
3550
3552
  }
3551
3553
  exports.downloadFilesInWorkPath = downloadFilesInWorkPath;
3552
3554
  const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, config, }) => {
3555
+ var _a, _b;
3556
+ let pipPath = meta.isDev ? 'pip3' : 'pip3.9';
3557
+ let pythonPath = meta.isDev ? 'python3' : 'python3.9';
3558
+ let pythonRuntime = meta.isDev ? 'python3' : 'python3.9';
3553
3559
  workPath = await downloadFilesInWorkPath({
3554
3560
  workPath,
3555
3561
  files: originalFiles,
@@ -3576,6 +3582,8 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
3576
3582
  }
3577
3583
  console.log('Installing required dependencies...');
3578
3584
  await install_1.installRequirement({
3585
+ pythonPath,
3586
+ pipPath,
3579
3587
  dependency: 'werkzeug',
3580
3588
  version: '1.0.1',
3581
3589
  workPath,
@@ -3590,12 +3598,41 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
3590
3598
  : null;
3591
3599
  if (pipfileLockDir) {
3592
3600
  build_utils_1.debug('Found "Pipfile.lock"');
3601
+ try {
3602
+ const json = await readFile(path_1.join(pipfileLockDir, 'Pipfile.lock'), 'utf8');
3603
+ const obj = JSON.parse(json);
3604
+ const version = (_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;
3605
+ if (!meta.isDev) {
3606
+ if (version === '3.6') {
3607
+ pipPath = 'pip3.6';
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
+ }
3621
+ }
3622
+ catch (err) {
3623
+ throw new build_utils_1.NowBuildError({
3624
+ code: 'INVALID_PIPFILE_LOCK',
3625
+ message: 'Unable to parse Pipfile.lock',
3626
+ });
3627
+ }
3593
3628
  // Convert Pipenv.Lock to requirements.txt.
3594
3629
  // We use a different`workPath` here because we want `pipfile-requirements` and it's dependencies
3595
3630
  // to not be part of the lambda environment. By using pip's `--target` directive we can isolate
3596
3631
  // it into a separate folder.
3597
3632
  const tempDir = await build_utils_1.getWriteableDirectory();
3598
3633
  await install_1.installRequirement({
3634
+ pythonPath,
3635
+ pipPath,
3599
3636
  dependency: 'pipfile-requirements',
3600
3637
  version: '0.3.0',
3601
3638
  workPath: tempDir,
@@ -3614,6 +3651,8 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
3614
3651
  build_utils_1.debug('Found local "requirements.txt"');
3615
3652
  const requirementsTxtPath = fsFiles[requirementsTxt].fsPath;
3616
3653
  await install_1.installRequirementsFile({
3654
+ pythonPath,
3655
+ pipPath,
3617
3656
  filePath: requirementsTxtPath,
3618
3657
  workPath,
3619
3658
  meta,
@@ -3623,13 +3662,15 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
3623
3662
  build_utils_1.debug('Found global "requirements.txt"');
3624
3663
  const requirementsTxtPath = fsFiles['requirements.txt'].fsPath;
3625
3664
  await install_1.installRequirementsFile({
3665
+ pythonPath,
3666
+ pipPath,
3626
3667
  filePath: requirementsTxtPath,
3627
3668
  workPath,
3628
3669
  meta,
3629
3670
  });
3630
3671
  }
3631
- const originalPyPath = __nccwpck_require__.ab + "vc_init.py";
3632
- const originalHandlerPyContents = await readFile(__nccwpck_require__.ab + "vc_init.py", 'utf8');
3672
+ const originalPyPath = __webpack_require__.ab + "vc_init.py";
3673
+ const originalHandlerPyContents = await readFile(__webpack_require__.ab + "vc_init.py", 'utf8');
3633
3674
  build_utils_1.debug('Entrypoint is', entrypoint);
3634
3675
  const moduleName = entrypoint.replace(/\//g, '.').replace(/\.py$/, '');
3635
3676
  // Since `vercel dev` renames source files, we must reference the original
@@ -3644,7 +3685,7 @@ const build = async ({ workPath, files: originalFiles, entrypoint, meta = {}, co
3644
3685
  const handlerPyFilename = 'vc__handler__python';
3645
3686
  await writeFile(path_1.join(workPath, `${handlerPyFilename}.py`), handlerPyContents);
3646
3687
  // Use the system-installed version of `python3` when running via `vercel dev`
3647
- const runtime = meta.isDev ? 'python3' : 'python3.6';
3688
+ const runtime = meta.isDev ? 'python3' : pythonRuntime;
3648
3689
  const globOptions = {
3649
3690
  cwd: workPath,
3650
3691
  ignore: config && typeof config.excludeFiles === 'string'
@@ -3665,7 +3706,7 @@ exports.build = build;
3665
3706
  /***/ }),
3666
3707
 
3667
3708
  /***/ 95:
3668
- /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
3709
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
3669
3710
 
3670
3711
  "use strict";
3671
3712
 
@@ -3674,18 +3715,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3674
3715
  };
3675
3716
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3676
3717
  exports.installRequirementsFile = exports.installRequirement = void 0;
3677
- const execa_1 = __importDefault(__nccwpck_require__(580));
3678
- const build_utils_1 = __nccwpck_require__(445);
3679
- const pipPath = 'pip3';
3718
+ const execa_1 = __importDefault(__webpack_require__(580));
3719
+ const build_utils_1 = __webpack_require__(445);
3680
3720
  const makeDependencyCheckCode = (dependency) => `
3681
3721
  from importlib import util
3682
3722
  dep = '${dependency}'.replace('-', '_')
3683
3723
  spec = util.find_spec(dep)
3684
3724
  print(spec.origin)
3685
3725
  `;
3686
- async function isInstalled(dependency, cwd) {
3726
+ async function isInstalled(pythonPath, dependency, cwd) {
3687
3727
  try {
3688
- const { stdout } = await execa_1.default('python3', ['-c', makeDependencyCheckCode(dependency)], {
3728
+ const { stdout } = await execa_1.default(pythonPath, ['-c', makeDependencyCheckCode(dependency)], {
3689
3729
  stdio: 'pipe',
3690
3730
  cwd,
3691
3731
  });
@@ -3702,9 +3742,9 @@ from pkg_resources import DistributionNotFound, VersionConflict
3702
3742
  dependencies = distutils.text_file.TextFile(filename='${requirementsPath}').readlines()
3703
3743
  pkg_resources.require(dependencies)
3704
3744
  `;
3705
- async function areRequirementsInstalled(requirementsPath, cwd) {
3745
+ async function areRequirementsInstalled(pythonPath, requirementsPath, cwd) {
3706
3746
  try {
3707
- await execa_1.default('python3', ['-c', makeRequirementsCheckCode(requirementsPath)], {
3747
+ await execa_1.default(pythonPath, ['-c', makeRequirementsCheckCode(requirementsPath)], {
3708
3748
  stdio: 'pipe',
3709
3749
  cwd,
3710
3750
  });
@@ -3714,7 +3754,7 @@ async function areRequirementsInstalled(requirementsPath, cwd) {
3714
3754
  return false;
3715
3755
  }
3716
3756
  }
3717
- async function pipInstall(workPath, args) {
3757
+ async function pipInstall(pipPath, workPath, args) {
3718
3758
  const target = '.';
3719
3759
  // See: https://github.com/pypa/pip/issues/4222#issuecomment-417646535
3720
3760
  //
@@ -3731,15 +3771,15 @@ async function pipInstall(workPath, args) {
3731
3771
  target,
3732
3772
  ...args,
3733
3773
  ];
3734
- build_utils_1.debug(`Running "pip3 ${cmdArgs.join(' ')}"...`);
3774
+ const pretty = `${pipPath} ${cmdArgs.join(' ')}`;
3775
+ build_utils_1.debug(`Running "${pretty}"...`);
3735
3776
  try {
3736
3777
  await execa_1.default(pipPath, cmdArgs, {
3737
3778
  cwd: workPath,
3738
- stdio: 'pipe',
3739
3779
  });
3740
3780
  }
3741
3781
  catch (err) {
3742
- console.log(`Failed to run "pip3 ${cmdArgs.join(' ')}"`);
3782
+ console.log(`Failed to run "${pretty}"`);
3743
3783
  throw err;
3744
3784
  }
3745
3785
  }
@@ -3747,21 +3787,22 @@ async function pipInstall(workPath, args) {
3747
3787
  // with this function can get overriden by a newer version from requirements.txt,
3748
3788
  // so vc_init should do runtime version checks to be compatible with any recent
3749
3789
  // version of its dependencies
3750
- async function installRequirement({ dependency, version, workPath, meta, args = [], }) {
3751
- if (meta.isDev && (await isInstalled(dependency, workPath))) {
3790
+ async function installRequirement({ pythonPath, pipPath, dependency, version, workPath, meta, args = [], }) {
3791
+ if (meta.isDev && (await isInstalled(pythonPath, dependency, workPath))) {
3752
3792
  build_utils_1.debug(`Skipping ${dependency} dependency installation, already installed in ${workPath}`);
3753
3793
  return;
3754
3794
  }
3755
3795
  const exact = `${dependency}==${version}`;
3756
- await pipInstall(workPath, [exact, ...args]);
3796
+ await pipInstall(pipPath, workPath, [exact, ...args]);
3757
3797
  }
3758
3798
  exports.installRequirement = installRequirement;
3759
- async function installRequirementsFile({ filePath, workPath, meta, args = [], }) {
3760
- if (meta.isDev && (await areRequirementsInstalled(filePath, workPath))) {
3799
+ async function installRequirementsFile({ pythonPath, pipPath, filePath, workPath, meta, args = [], }) {
3800
+ if (meta.isDev &&
3801
+ (await areRequirementsInstalled(pythonPath, filePath, workPath))) {
3761
3802
  build_utils_1.debug(`Skipping requirements file installation, already installed`);
3762
3803
  return;
3763
3804
  }
3764
- await pipInstall(workPath, ['--upgrade', '-r', filePath, ...args]);
3805
+ await pipInstall(pipPath, workPath, ['--upgrade', '-r', filePath, ...args]);
3765
3806
  }
3766
3807
  exports.installRequirementsFile = installRequirementsFile;
3767
3808
 
@@ -3838,11 +3879,10 @@ module.exports = require("util");
3838
3879
  /******/ var __webpack_module_cache__ = {};
3839
3880
  /******/
3840
3881
  /******/ // The require function
3841
- /******/ function __nccwpck_require__(moduleId) {
3882
+ /******/ function __webpack_require__(moduleId) {
3842
3883
  /******/ // Check if module is in cache
3843
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
3844
- /******/ if (cachedModule !== undefined) {
3845
- /******/ return cachedModule.exports;
3884
+ /******/ if(__webpack_module_cache__[moduleId]) {
3885
+ /******/ return __webpack_module_cache__[moduleId].exports;
3846
3886
  /******/ }
3847
3887
  /******/ // Create a new module (and put it into the cache)
3848
3888
  /******/ var module = __webpack_module_cache__[moduleId] = {
@@ -3854,7 +3894,7 @@ module.exports = require("util");
3854
3894
  /******/ // Execute the module function
3855
3895
  /******/ var threw = true;
3856
3896
  /******/ try {
3857
- /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __nccwpck_require__);
3897
+ /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
3858
3898
  /******/ threw = false;
3859
3899
  /******/ } finally {
3860
3900
  /******/ if(threw) delete __webpack_module_cache__[moduleId];
@@ -3867,15 +3907,10 @@ module.exports = require("util");
3867
3907
  /************************************************************************/
3868
3908
  /******/ /* webpack/runtime/compat */
3869
3909
  /******/
3870
- /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
3871
- /******/
3872
- /************************************************************************/
3873
- /******/
3910
+ /******/ __webpack_require__.ab = __dirname + "/";/************************************************************************/
3911
+ /******/ // module exports must be returned from runtime so entry inlining is disabled
3874
3912
  /******/ // startup
3875
3913
  /******/ // Load entry module and return exports
3876
- /******/ // This entry module is referenced by other modules so it can't be inlined
3877
- /******/ var __webpack_exports__ = __nccwpck_require__(855);
3878
- /******/ module.exports = __webpack_exports__;
3879
- /******/
3914
+ /******/ return __webpack_require__(855);
3880
3915
  /******/ })()
3881
3916
  ;
@@ -0,0 +1,21 @@
1
+ import { Meta } from '@vercel/build-utils';
2
+ interface InstallRequirementArg {
3
+ pythonPath: string;
4
+ pipPath: string;
5
+ dependency: string;
6
+ version: string;
7
+ workPath: string;
8
+ meta: Meta;
9
+ args?: string[];
10
+ }
11
+ export declare function installRequirement({ pythonPath, pipPath, dependency, version, workPath, meta, args, }: InstallRequirementArg): Promise<void>;
12
+ interface InstallRequirementsFileArg {
13
+ pythonPath: string;
14
+ pipPath: string;
15
+ filePath: string;
16
+ workPath: string;
17
+ meta: Meta;
18
+ args?: string[];
19
+ }
20
+ export declare function installRequirementsFile({ pythonPath, pipPath, filePath, workPath, meta, args, }: InstallRequirementsFileArg): Promise<void>;
21
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/python",
3
- "version": "2.0.6-canary.3",
3
+ "version": "2.0.6-canary.7",
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.31.1",
23
+ "@vercel/ncc": "0.24.0",
24
24
  "execa": "^1.0.0",
25
25
  "typescript": "4.3.4"
26
26
  },
27
- "gitHead": "07c369c542913c3625c5e6a5d22807e3cf384401"
27
+ "gitHead": "f4501433c85f3f16466ef7f450c6b9213d2e1ef7"
28
28
  }