Skip to content

Commit 7af954e

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents d52b14f + c1f5ca1 commit 7af954e

File tree

15 files changed

+68
-23
lines changed

15 files changed

+68
-23
lines changed

.github/workflows/integrate.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ jobs:
117117
linuxNode12:
118118
name: '[Linux] Node.js v12: Unit tests'
119119
runs-on: ubuntu-latest
120+
strategy:
121+
matrix:
122+
sls-version: [2, 3]
123+
pipenv-version: ['2022.8.5', '2022.8.13']
120124
steps:
121125
- name: Checkout repository
122126
uses: actions/checkout@v2
@@ -165,10 +169,6 @@ jobs:
165169
tagIfNewVersion:
166170
name: Tag if new version
167171
runs-on: ubuntu-latest
168-
strategy:
169-
matrix:
170-
sls-version: [2, 3]
171-
pipenv-version: ['2022.8.5', '2022.8.13']
172172
needs: [windowsNode14, linuxNode14, linuxNode12]
173173
steps:
174174
- name: Checkout repository

.github/workflows/validate.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ jobs:
1616
strategy:
1717
matrix:
1818
sls-version: [2, 3]
19-
pipenv-version: ['2022.8.5', '2022.8.13']
19+
pipenv-version: ['2022.8.5', '2022.8.13', '2023.7.4', '2023.7.9']
20+
# pipenv 2202.8.13 marks deprecation of pipenv lock --requirements
21+
# https://github.com/pypa/pipenv/blob/30067b458bd7a429f242736b7fde40c9bd4d4f14/CHANGELOG.rst#2022813-2022-08-13
22+
# pipenv 2023.7.9 marks deprecation of pipenv lock --keep-outdated
23+
# https://github.com/pypa/pipenv/blob/30067b458bd7a429f242736b7fde40c9bd4d4f14/CHANGELOG.rst#202379-2023-07-09
2024
steps:
2125
- name: Checkout repository
2226
uses: actions/checkout@v2
@@ -95,7 +99,7 @@ jobs:
9599
strategy:
96100
matrix:
97101
sls-version: [2, 3]
98-
pipenv-version: ['2022.8.5', '2022.8.13']
102+
pipenv-version: ['2022.8.5', '2022.8.13', '2023.7.4', '2023.7.9']
99103
steps:
100104
- name: Checkout repository
101105
uses: actions/checkout@v2
@@ -149,7 +153,7 @@ jobs:
149153
strategy:
150154
matrix:
151155
sls-version: [2, 3]
152-
pipenv-version: ['2022.8.5', '2022.8.13']
156+
pipenv-version: ['2022.8.5', '2022.8.13', '2023.7.4', '2023.7.9']
153157
steps:
154158
- name: Checkout repository
155159
uses: actions/checkout@v2

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,6 @@ unzip_requirements.py
7676
# Project ignores
7777
puck/
7878
serverless.yml.bak
79+
80+
# Generated packaging
81+
*.tgz

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.7

CONTRIBUTING.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,17 @@ Welcome, and thanks in advance for your help!
1212

1313
## Setup
1414

15-
It is recommended to use Node v14 or v16 for development.
16-
17-
Then, to begin development fork repository and run `npm install` in its root folder.
15+
Pre-Reqs:
16+
* Python 3.7
17+
* [poetry](https://python-poetry.org/docs/) (if you use multiple versions of Python be sure to install it with python 3.7)
18+
* Perl (used in the tests)
19+
* Node v14 or v16
20+
21+
Then, to begin development:
22+
1. fork the repository
23+
2. `npm install -g serverless@<VERSION>` (check the peer dependencies in the root `package.json` file for the version)
24+
3. run `npm install` in its root folder
25+
4. run the tests via `npm run test`
1826

1927
## Getting started
2028

index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ class ServerlessPythonRequirements {
7070
// "google" and "scaleway" providers' runtimes uses python3XX
7171
options.pythonBin = options.pythonBin.replace(/3([0-9]+)/, '3.$1');
7272
}
73+
if (
74+
options.pythonBin === this.serverless.service.provider.runtime &&
75+
!options.pythonBin.startsWith('python')
76+
) {
77+
options.pythonBin = 'python';
78+
}
79+
7380
if (options.dockerizePip === 'non-linux') {
7481
options.dockerizePip = process.platform !== 'linux';
7582
}

lib/pipenv.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,26 +77,36 @@ async function pipfileToRequirements() {
7777

7878
if (semver.gt(pipenvVersion, LEGACY_PIPENV_VERSION)) {
7979
// Using new pipenv syntax ( >= 2022.8.13)
80+
// Generate requirements from existing lock file.
81+
// See: https://pipenv.pypa.io/en/latest/advanced/#generating-a-requirements-txt
8082
try {
81-
await spawn('pipenv', ['lock', '--keep-outdated'], {
83+
res = await spawn('pipenv', ['requirements'], {
8284
cwd: this.servicePath,
8385
});
8486
} catch (e) {
8587
const stderrBufferContent =
8688
(e.stderrBuffer && e.stderrBuffer.toString()) || '';
87-
if (stderrBufferContent.includes('must exist to use')) {
89+
if (stderrBufferContent.includes('FileNotFoundError')) {
8890
// No previous Pipfile.lock, we will try to generate it here
91+
if (this.log) {
92+
this.log.warning(
93+
'No Pipfile.lock found! Review https://pipenv.pypa.io/en/latest/pipfile/ for recommendations.'
94+
);
95+
} else {
96+
this.serverless.cli.log(
97+
'WARNING: No Pipfile.lock found! Review https://pipenv.pypa.io/en/latest/pipfile/ for recommendations.'
98+
);
99+
}
89100
await spawn('pipenv', ['lock'], {
90101
cwd: this.servicePath,
91102
});
103+
res = await spawn('pipenv', ['requirements'], {
104+
cwd: this.servicePath,
105+
});
92106
} else {
93107
throw e;
94108
}
95109
}
96-
97-
res = await spawn('pipenv', ['requirements'], {
98-
cwd: this.servicePath,
99-
});
100110
} else {
101111
// Falling back to legacy pipenv syntax
102112
res = await spawn(

test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,18 @@ test('poetry py3.7 fails packaging if poetry.lock is missing and flag requirePoe
16551655
t.end();
16561656
});
16571657

1658+
test('works with provider.runtime not being python', async (t) => {
1659+
process.chdir('tests/base');
1660+
const path = npm(['pack', '../..']);
1661+
npm(['i', path]);
1662+
sls(['package'], { env: { runtime: 'nodejs12.x' } });
1663+
t.true(
1664+
pathExistsSync('.serverless/sls-py-req-test.zip'),
1665+
'sls-py-req-test is packaged'
1666+
);
1667+
t.end();
1668+
});
1669+
16581670
test('poetry py3.7 packages additional optional packages', async (t) => {
16591671
process.chdir('tests/poetry_packages');
16601672
const path = npm(['pack', '../..']);

tests/base/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"author": "",
1010
"license": "ISC",
1111
"dependencies": {
12-
"serverless-python-requirements": "file:serverless-python-requirements-5.3.1.tgz"
12+
"serverless-python-requirements": "file:serverless-python-requirements-6.0.0.tgz"
1313
}
1414
}

tests/individually/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"author": "",
1010
"license": "ISC",
1111
"dependencies": {
12-
"serverless-python-requirements": "file:serverless-python-requirements-5.1.1.tgz"
12+
"serverless-python-requirements": "file:serverless-python-requirements-6.0.0.tgz"
1313
}
1414
}

tests/non_build_pyproject/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"author": "",
1010
"license": "ISC",
1111
"dependencies": {
12-
"serverless-python-requirements": "file:serverless-python-requirements-5.3.1.tgz"
12+
"serverless-python-requirements": "file:serverless-python-requirements-6.0.0.tgz"
1313
}
1414
}

tests/non_poetry_pyproject/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"author": "",
1010
"license": "ISC",
1111
"dependencies": {
12-
"serverless-python-requirements": "file:serverless-python-requirements-5.3.1.tgz"
12+
"serverless-python-requirements": "file:serverless-python-requirements-6.0.0.tgz"
1313
}
1414
}

tests/pipenv/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"author": "",
1010
"license": "ISC",
1111
"dependencies": {
12-
"serverless-python-requirements": "file:serverless-python-requirements-5.3.1.tgz"
12+
"serverless-python-requirements": "file:serverless-python-requirements-6.0.0.tgz"
1313
}
1414
}

tests/poetry/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"author": "",
1010
"license": "ISC",
1111
"dependencies": {
12-
"serverless-python-requirements": "file:serverless-python-requirements-5.3.1.tgz"
12+
"serverless-python-requirements": "file:serverless-python-requirements-6.0.0.tgz"
1313
}
1414
}

tests/poetry_individually/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"author": "",
1010
"license": "ISC",
1111
"dependencies": {
12-
"serverless-python-requirements": "file:serverless-python-requirements-5.3.1.tgz"
12+
"serverless-python-requirements": "file:serverless-python-requirements-6.0.0.tgz"
1313
}
1414
}

0 commit comments

Comments
 (0)