Skip to content

Commit 6f1b801

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

File tree

4 files changed

+27
-292
lines changed

4 files changed

+27
-292
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

+21-5
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,26 @@ 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) {
36+
if (
37+
e.stderrBuffer &&
38+
e.stderrBuffer.toString().includes('must exist to use')
39+
) {
40+
// No previous Pipfile.lock, we will try to generate it here
41+
try {
42+
await spawn('pipenv', ['lock'], {
43+
cwd: this.servicePath,
44+
});
45+
} catch (e) {
46+
console.log('weird', e.stderrBuffer.toString());
47+
throw e;
48+
}
49+
}
50+
4051
if (
4152
e.stderrBuffer &&
4253
e.stderrBuffer.toString().includes('command not found')
@@ -46,8 +57,13 @@ async function pipfileToRequirements() {
4657
'PYTHON_REQUIREMENTS_PIPENV_NOT_FOUND'
4758
);
4859
}
60+
4961
throw e;
5062
}
63+
const res = await spawn('pipenv', ['requirements'], {
64+
cwd: this.servicePath,
65+
});
66+
5167
fse.ensureDirSync(path.join(this.servicePath, '.serverless'));
5268
fse.writeFileSync(
5369
path.join(this.servicePath, '.serverless/requirements.txt'),

tests/pipenv/Pipfile.lock

-281
This file was deleted.

0 commit comments

Comments
 (0)