diff --git a/index.js b/index.js index 50a005e1..246b121e 100644 --- a/index.js +++ b/index.js @@ -66,6 +66,13 @@ class ServerlessPythonRequirements { this.serverless.service.custom.pythonRequirements) || {} ); + if ( + options.pythonBin === this.serverless.service.provider.runtime && + !options.pythonBin.startsWith('python') + ) { + options.pythonBin = 'python'; + } + if (options.dockerizePip === 'non-linux') { options.dockerizePip = process.platform !== 'linux'; } diff --git a/test.js b/test.js index c7232a6e..1f646e9c 100644 --- a/test.js +++ b/test.js @@ -1655,6 +1655,15 @@ test('poetry py3.7 fails packaging if poetry.lock is missing and flag requirePoe t.end(); }); +test('works with provider.runtime not being python', async (t) => { + process.chdir('tests/base'); + const path = npm(['pack', '../..']); + npm(['i', path]); + sls(['package'], { env: { runtime: 'nodejs12.x' } }); + t.true(pathExistsSync('.serverless/hello.zip'), 'function hello is packaged'); + t.end(); +}); + test('poetry py3.7 packages additional optional packages', async (t) => { process.chdir('tests/poetry_packages'); const path = npm(['pack', '../..']);