Skip to content

Commit a9e5ef0

Browse files
committed
feat: Ensure support when Pipfile.lock missing
1 parent ef4f0cc commit a9e5ef0

File tree

5 files changed

+21
-295
lines changed

5 files changed

+21
-295
lines changed

.github/workflows/integrate.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
run: python -m pip install --force setuptools wheel
4949

5050
- name: Install pipenv / poetry
51-
run: python -m pip install pipenv==2022.9.24 poetry
51+
run: python -m pip install pipenv poetry
5252

5353
- name: Install serverless
5454
run: npm install -g serverless@${{ matrix.sls-version }}
@@ -99,7 +99,7 @@ jobs:
9999
run: python -m pip install --force setuptools wheel
100100

101101
- name: Install pipenv / poetry
102-
run: python -m pip install pipenv==2022.9.24 poetry
102+
run: python -m pip install pipenv poetry
103103

104104
- name: Install serverless
105105
run: npm install -g serverless@${{ matrix.sls-version }}
@@ -147,7 +147,7 @@ jobs:
147147
run: python -m pip install --force setuptools wheel
148148

149149
- name: Install pipenv / poetry
150-
run: python -m pip install pipenv==2022.9.24 poetry
150+
run: python -m pip install pipenv poetry
151151

152152
- name: Install serverless
153153
run: npm install -g serverless@${{ matrix.sls-version }}

.github/workflows/validate.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
run: python -m pip install --force setuptools wheel
6262

6363
- name: Install pipenv / poetry
64-
run: python -m pip install pipenv==2022.9.24 poetry
64+
run: python -m pip install pipenv poetry
6565

6666
- name: Install serverless
6767
run: npm install -g serverless@${{ matrix.sls-version }}
@@ -128,7 +128,7 @@ jobs:
128128
run: python -m pip install --force setuptools wheel
129129

130130
- name: Install pipenv / poetry
131-
run: python -m pip install pipenv==2022.9.24 poetry
131+
run: python -m pip install pipenv poetry
132132

133133
- name: Install serverless
134134
run: npm install -g serverless@${{ matrix.sls-version }}
@@ -181,7 +181,7 @@ jobs:
181181
run: python -m pip install --force setuptools wheel
182182

183183
- name: Install pipenv / poetry
184-
run: python -m pip install pipenv==2022.9.24 poetry
184+
run: python -m pip install pipenv poetry
185185

186186
- name: Install serverless
187187
run: npm install -g serverless@${{ matrix.sls-version }}

lib/pipenv.js

+14-6
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'], {
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

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[[source]]
2-
url = "https://pypi.org/simple"
2+
url = "https://pypi.python.org/simple"
33
verify_ssl = true
4-
name = "pypi"
54

65
[packages]
76
Flask = "==2.0.3"

tests/pipenv/Pipfile.lock

-281
This file was deleted.

0 commit comments

Comments
 (0)