diff --git a/.gitignore b/.gitignore index 3707ff1e..64bdbd6a 100644 --- a/.gitignore +++ b/.gitignore @@ -76,3 +76,6 @@ unzip_requirements.py # Project ignores puck/ serverless.yml.bak + +# Generated packaging +*.tgz diff --git a/.python-version b/.python-version new file mode 100644 index 00000000..475ba515 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.7 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index efcf6d1f..4616858b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,9 +12,17 @@ Welcome, and thanks in advance for your help! ## Setup -It is recommended to use Node v14 or v16 for development. - -Then, to begin development fork repository and run `npm install` in its root folder. +Pre-Reqs: +* Python 3.7 +* [poetry](https://python-poetry.org/docs/) (if you use multiple versions of Python be sure to install it with python 3.7) +* Perl (used in the tests) +* Node v14 or v16 + +Then, to begin development: +1. fork the repository +2. `npm install -g serverless@` (check the peer dependencies in the root `package.json` file for the version) +3. run `npm install` in its root folder +4. run the tests via `npm run test` ## Getting started 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..673bf631 100644 --- a/test.js +++ b/test.js @@ -1655,6 +1655,18 @@ 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/sls-py-req-test.zip'), + 'sls-py-req-test is packaged' + ); + t.end(); +}); + test('poetry py3.7 packages additional optional packages', async (t) => { process.chdir('tests/poetry_packages'); const path = npm(['pack', '../..']);