Skip to content

Commit ce329e6

Browse files
committed
feat: Ensure support when Pipfile.lock missing
1 parent 57b36af commit ce329e6

File tree

4 files changed

+20
-293
lines changed

4 files changed

+20
-293
lines changed

.github/workflows/integrate.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
run: python -m pip install --force setuptools wheel
4646

4747
- name: Install pipenv / poetry
48-
run: python -m pip install pipenv==2022.9.24 poetry
48+
run: python -m pip install pipenv poetry
4949

5050
- name: Install serverless
5151
run: npm install -g serverless@2
@@ -93,7 +93,7 @@ jobs:
9393
run: python -m pip install --force setuptools wheel
9494

9595
- name: Install pipenv / poetry
96-
run: python -m pip install pipenv==2022.9.24 poetry
96+
run: python -m pip install pipenv poetry
9797

9898
- name: Install serverless
9999
run: npm install -g serverless@2
@@ -141,7 +141,7 @@ jobs:
141141
run: python -m pip install --force setuptools wheel
142142

143143
- name: Install pipenv / poetry
144-
run: python -m pip install pipenv==2022.9.24 poetry
144+
run: python -m pip install pipenv poetry
145145

146146
- name: Install serverless
147147
run: npm install -g serverless@2

.github/workflows/validate.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
run: python -m pip install --force setuptools wheel
5959

6060
- name: Install pipenv / poetry
61-
run: python -m pip install pipenv==2022.9.24 poetry
61+
run: python -m pip install pipenv poetry
6262

6363
- name: Install serverless
6464
run: npm install -g serverless@2
@@ -122,7 +122,7 @@ jobs:
122122
run: python -m pip install --force setuptools wheel
123123

124124
- name: Install pipenv / poetry
125-
run: python -m pip install pipenv==2022.9.24 poetry
125+
run: python -m pip install pipenv poetry
126126

127127
- name: Install serverless
128128
run: npm install -g serverless@2
@@ -172,7 +172,7 @@ jobs:
172172
run: python -m pip install --force setuptools wheel
173173

174174
- name: Install pipenv / poetry
175-
run: python -m pip install pipenv==2022.9.24 poetry
175+
run: python -m pip install pipenv poetry
176176

177177
- name: Install serverless
178178
run: npm install -g serverless@2

lib/pipenv.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,8 @@ async function pipfileToRequirements() {
2828
}
2929

3030
try {
31-
let res;
3231
try {
33-
res = await spawn('pipenv', ['lock', '--keep-outdated'], {
34-
cwd: this.servicePath,
35-
});
36-
res = await spawn('pipenv', ['requirements', '--hash'], {
32+
await spawn('pipenv', ['lock', '--keep-outdated'], {
3733
cwd: this.servicePath,
3834
});
3935
} catch (e) {
@@ -46,8 +42,20 @@ async function pipfileToRequirements() {
4642
'PYTHON_REQUIREMENTS_PIPENV_NOT_FOUND'
4743
);
4844
}
49-
throw e;
45+
if (
46+
e.stderrBuffer &&
47+
e.stderrBuffer.toString().includes('Pipfile.lock must exist')
48+
) {
49+
// No previous Pipfile.lock, we will try to generate it here
50+
await spawn('pipenv', ['lock'], {
51+
cwd: this.servicePath,
52+
});
53+
}
5054
}
55+
const res = await spawn('pipenv', ['requirements', '--hash'], {
56+
cwd: this.servicePath,
57+
});
58+
5159
fse.ensureDirSync(path.join(this.servicePath, '.serverless'));
5260
fse.writeFileSync(
5361
path.join(this.servicePath, '.serverless/requirements.txt'),

tests/pipenv/Pipfile.lock

Lines changed: 0 additions & 281 deletions
This file was deleted.

0 commit comments

Comments
 (0)