Skip to content

Commit a43b762

Browse files
authored
Merge branch 'master' into poetry-overwrite-requirements-file
2 parents 5b38b5c + 64e20db commit a43b762

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ custom:
239239

240240
## Extra Config Options
241241
### Caching
242-
You can enable two kinds of caching with this plugin which are currently both DISABLED by default. First, a download cache that will cache downloads that pip needs to compile the packages. And second, a what we call "static caching" which caches output of pip after compiling everything for your requirements file. Since generally requirements.txt files rarely change, you will often see large amounts of speed improvements when enabling the static cache feature. These caches will be shared between all your projects if no custom cacheLocation is specified (see below).
242+
You can enable two kinds of caching with this plugin which are currently both ENABLED by default. First, a download cache that will cache downloads that pip needs to compile the packages. And second, a what we call "static caching" which caches output of pip after compiling everything for your requirements file. Since generally requirements.txt files rarely change, you will often see large amounts of speed improvements when enabling the static cache feature. These caches will be shared between all your projects if no custom cacheLocation is specified (see below).
243243

244244
_**Please note:** This has replaced the previously recommended usage of "--cache-dir" in the pipCmdExtraArgs_
245245
```yaml

lib/inject.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,20 @@ function moveModuleUp(source, target, module) {
6262
return fse
6363
.readFileAsync(source)
6464
.then(buffer => JSZip.loadAsync(buffer))
65-
.then(sourceZip => sourceZip.filter(file => file.startsWith(module + '/')))
65+
.then(sourceZip =>
66+
sourceZip.filter(
67+
file =>
68+
file.startsWith(module + '/') ||
69+
file.startsWith('serverless_sdk/') ||
70+
file.match(/s_.*\.py/) !== null
71+
)
72+
)
6673
.map(srcZipObj =>
6774
zipFile(
6875
targetZip,
69-
srcZipObj.name.replace(module + '/', ''),
76+
srcZipObj.name.startsWith(module + '/')
77+
? srcZipObj.name.replace(module + '/', '')
78+
: srcZipObj.name,
7079
srcZipObj.async('nodebuffer')
7180
)
7281
)

lib/pip.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,16 @@ function installRequirements(targetFolder, serverless, options) {
123123
options.pythonBin,
124124
'-m',
125125
'pip',
126-
'install',
127-
...options.pipCmdExtraArgs
126+
'install'
128127
];
128+
129+
if (Array.isArray(options.pipCmdExtraArgs) && options.pipCmdExtraArgs.length > 0) {
130+
options.pipCmdExtraArgs.forEach(cmd => {
131+
const parts = cmd.split(/\s+/, 2);
132+
pipCmd.push(...parts);
133+
});
134+
}
135+
129136
const pipCmds = [pipCmd];
130137
const postCmds = [];
131138
// Check if we're using the legacy --cache-dir command...

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "serverless-python-requirements",
3-
"version": "5.0.0",
3+
"version": "5.0.1",
44
"engines": {
55
"node": ">=6.0"
66
},

0 commit comments

Comments
 (0)