Skip to content

Commit

Permalink
fix: Remove outdated Pipenv requirements flag (#780)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfgordon2 authored Aug 17, 2023
1 parent e8b2e51 commit ad40278
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 16 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ jobs:
strategy:
matrix:
sls-version: [2, 3]
pipenv-version: ['2022.8.5', '2022.8.13']
pipenv-version: ['2022.8.5', '2022.8.13', '2023.7.4', '2023.7.9']
# pipenv 2202.8.13 marks deprecation of pipenv lock --requirements
# https://github.com/pypa/pipenv/blob/30067b458bd7a429f242736b7fde40c9bd4d4f14/CHANGELOG.rst#2022813-2022-08-13
# pipenv 2023.7.9 marks deprecation of pipenv lock --keep-outdated
# https://github.com/pypa/pipenv/blob/30067b458bd7a429f242736b7fde40c9bd4d4f14/CHANGELOG.rst#202379-2023-07-09
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down Expand Up @@ -95,7 +99,7 @@ jobs:
strategy:
matrix:
sls-version: [2, 3]
pipenv-version: ['2022.8.5', '2022.8.13']
pipenv-version: ['2022.8.5', '2022.8.13', '2023.7.4', '2023.7.9']
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down Expand Up @@ -149,7 +153,7 @@ jobs:
strategy:
matrix:
sls-version: [2, 3]
pipenv-version: ['2022.8.5', '2022.8.13']
pipenv-version: ['2022.8.5', '2022.8.13', '2023.7.4', '2023.7.9']
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down
22 changes: 16 additions & 6 deletions lib/pipenv.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,36 @@ async function pipfileToRequirements() {

if (semver.gt(pipenvVersion, LEGACY_PIPENV_VERSION)) {
// Using new pipenv syntax ( >= 2022.8.13)
// Generate requirements from existing lock file.
// See: https://pipenv.pypa.io/en/latest/advanced/#generating-a-requirements-txt
try {
await spawn('pipenv', ['lock', '--keep-outdated'], {
res = await spawn('pipenv', ['requirements'], {
cwd: this.servicePath,
});
} catch (e) {
const stderrBufferContent =
(e.stderrBuffer && e.stderrBuffer.toString()) || '';
if (stderrBufferContent.includes('must exist to use')) {
if (stderrBufferContent.includes('FileNotFoundError')) {
// No previous Pipfile.lock, we will try to generate it here
if (this.log) {
this.log.warning(
'No Pipfile.lock found! Review https://pipenv.pypa.io/en/latest/pipfile/ for recommendations.'
);
} else {
this.serverless.cli.log(
'WARNING: No Pipfile.lock found! Review https://pipenv.pypa.io/en/latest/pipfile/ for recommendations.'
);
}
await spawn('pipenv', ['lock'], {
cwd: this.servicePath,
});
res = await spawn('pipenv', ['requirements'], {
cwd: this.servicePath,
});
} else {
throw e;
}
}

res = await spawn('pipenv', ['requirements'], {
cwd: this.servicePath,
});
} else {
// Falling back to legacy pipenv syntax
res = await spawn(
Expand Down
2 changes: 1 addition & 1 deletion tests/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"author": "",
"license": "ISC",
"dependencies": {
"serverless-python-requirements": "file:serverless-python-requirements-5.3.1.tgz"
"serverless-python-requirements": "file:serverless-python-requirements-6.0.0.tgz"
}
}
2 changes: 1 addition & 1 deletion tests/individually/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"author": "",
"license": "ISC",
"dependencies": {
"serverless-python-requirements": "file:serverless-python-requirements-5.1.1.tgz"
"serverless-python-requirements": "file:serverless-python-requirements-6.0.0.tgz"
}
}
2 changes: 1 addition & 1 deletion tests/non_build_pyproject/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"author": "",
"license": "ISC",
"dependencies": {
"serverless-python-requirements": "file:serverless-python-requirements-5.3.1.tgz"
"serverless-python-requirements": "file:serverless-python-requirements-6.0.0.tgz"
}
}
2 changes: 1 addition & 1 deletion tests/non_poetry_pyproject/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"author": "",
"license": "ISC",
"dependencies": {
"serverless-python-requirements": "file:serverless-python-requirements-5.3.1.tgz"
"serverless-python-requirements": "file:serverless-python-requirements-6.0.0.tgz"
}
}
2 changes: 1 addition & 1 deletion tests/pipenv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"author": "",
"license": "ISC",
"dependencies": {
"serverless-python-requirements": "file:serverless-python-requirements-5.3.1.tgz"
"serverless-python-requirements": "file:serverless-python-requirements-6.0.0.tgz"
}
}
2 changes: 1 addition & 1 deletion tests/poetry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"author": "",
"license": "ISC",
"dependencies": {
"serverless-python-requirements": "file:serverless-python-requirements-5.3.1.tgz"
"serverless-python-requirements": "file:serverless-python-requirements-6.0.0.tgz"
}
}
2 changes: 1 addition & 1 deletion tests/poetry_individually/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"author": "",
"license": "ISC",
"dependencies": {
"serverless-python-requirements": "file:serverless-python-requirements-5.3.1.tgz"
"serverless-python-requirements": "file:serverless-python-requirements-6.0.0.tgz"
}
}

0 comments on commit ad40278

Please sign in to comment.