Skip to content

Commit 72e5565

Browse files
authored
Merge branch 'master' into master
2 parents 0362dee + 9934bf7 commit 72e5565

File tree

3 files changed

+46
-24
lines changed

3 files changed

+46
-24
lines changed

README.md

+36-17
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This will automatically add the plugin to your project's `package.json` and the
2121
`serverless.yml`. That's all that's needed for basic use! The plugin will now bundle your python
2222
dependencies specified in your `requirements.txt` or `Pipfile` when you run `sls deploy`.
2323

24-
For a more in depth introduction on how to user this plugin, check out
24+
For a more in depth introduction on how to user this plugin, check out
2525
[this post on the Serverless Blog](https://serverless.com/blog/serverless-python-packaging/)
2626

2727
If you're on a mac, check out [these notes](#applebeersnake-mac-brew-installed-python-notes) about using python installed by brew.
@@ -113,17 +113,17 @@ except ImportError:
113113
pass
114114
```
115115
### Slim Package
116-
_Works on non 'win32' environments: Docker, WSL are included_
117-
To remove the tests, information and caches from the installed packages,
118-
enable the `slim` option. This will: `strip` the `.so` files, remove `__pycache__`
119-
and `dist-info` directories as well as `.pyc` and `.pyo` files.
116+
_Works on non 'win32' environments: Docker, WSL are included_
117+
To remove the tests, information and caches from the installed packages,
118+
enable the `slim` option. This will: `strip` the `.so` files, remove `__pycache__`
119+
and `dist-info` directories as well as `.pyc` and `.pyo` files.
120120
```yaml
121121
custom:
122122
pythonRequirements:
123123
slim: true
124-
```
125-
#### Custom Removal Patterns
126-
To specify additional directories to remove from the installed packages,
124+
```
125+
#### Custom Removal Patterns
126+
To specify additional directories to remove from the installed packages,
127127
define a list of patterns in the serverless config using the `slimPatterns`
128128
option and glob syntax. These paterns will be added to the default ones (`**/*.py[c|o]`, `**/__pycache__*`, `**/*.dist-info*`).
129129
Note, the glob syntax matches against whole paths, so to match a file in any
@@ -134,7 +134,7 @@ custom:
134134
slim: true
135135
slimPatterns:
136136
- "**/*.egg-info*"
137-
```
137+
```
138138
To overwrite the default patterns set the option `slimPatternsAppendDefaults` to `false` (`true` by default).
139139
```yaml
140140
custom:
@@ -143,21 +143,40 @@ custom:
143143
slimPatternsAppendDefaults: false
144144
slimPatterns:
145145
- "**/*.egg-info*"
146-
```
147-
This will remove all folders within the installed requirements that match
148-
the names in `slimPatterns`
149-
## Omitting Packages
146+
```
147+
This will remove all folders within the installed requirements that match
148+
the names in `slimPatterns`
149+
## Omitting Packages
150150
You can omit a package from deployment with the `noDeploy` option. Note that
151-
dependencies of omitted packages must explicitly be omitted too.
152-
By default, this will not install the AWS SDKs that are already installed on
153-
Lambda. This example makes it instead omit pytest:
151+
dependencies of omitted packages must explicitly be omitted too. By default,
152+
the following packages are omitted as they are already installed on Lambda:
153+
154+
* boto3
155+
* botocore
156+
* docutils
157+
* jmespath
158+
* pip
159+
* python-dateutil
160+
* s3transfer
161+
* setuptools
162+
* six
163+
164+
This example makes it instead omit pytest:
154165
```yaml
155166
custom:
156167
pythonRequirements:
157168
noDeploy:
158169
- pytest
159170
```
160171

172+
To include the default omitted packages, set the `noDeploy` option to an empty
173+
list:
174+
```yaml
175+
custom:
176+
pythonRequirements:
177+
noDeploy: []
178+
```
179+
161180
## Extra Config Options
162181
### Caching
163182
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).
@@ -180,7 +199,7 @@ custom:
180199
useDownloadCache: true
181200
cacheLocation: '/home/user/.my_cache_goes_here'
182201
staticCacheMaxVersions: 10
183-
202+
184203
```
185204

186205
### Extra pip arguments

index.js

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ class ServerlessPythonRequirements {
6969
if (options.dockerizePip === 'non-linux') {
7070
options.dockerizePip = process.platform !== 'linux';
7171
}
72+
if (options.dockerizePip && process.platform === 'win32') {
73+
options.pythonBin = 'python';
74+
}
7275
if (
7376
!options.dockerizePip &&
7477
(options.dockerSsh || options.dockerImage || options.dockerFile)

test.bats

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ setup() {
88
export LANG=C.UTF-8
99
fi
1010
export USR_CACHE_DIR=`node -e 'console.log(require("./lib/shared").getUserCachePath())'`
11-
# Please note: If you update change the requirements.txt in test/base this value will
11+
# Please note: If you update change the requirements.txt in test/base this value will
1212
# change. Run a test which uses this variable manually step by step and list the cache
1313
# folder to find the new hash if you do this
1414
if [ -d "${USR_CACHE_DIR}" ] ; then
@@ -71,7 +71,7 @@ teardown() {
7171
unzip .serverless/sls-py-req-test.zip -d puck
7272
ls puck/flask
7373
test $(find puck -name "*.pyc" | wc -l) -eq 0
74-
test $(find puck -type d -name "*.egg-info*" | wc -l) -eq 0
74+
test $(find puck -type d -name "*.egg-info*" | wc -l) -eq 0
7575
}
7676

7777
@test "py3.6 doesn't package boto3 by default" {
@@ -143,7 +143,7 @@ teardown() {
143143
unzip .serverless/sls-py-req-test.zip -d puck
144144
ls puck/flask
145145
test $(find puck -name "*.pyc" | wc -l) -eq 0
146-
test $(find puck -type d -name "*.egg-info*" | wc -l) -eq 0
146+
test $(find puck -type d -name "*.egg-info*" | wc -l) -eq 0
147147
}
148148

149149
@test "py3.6 uses download cache with useDownloadCache option" {
@@ -279,7 +279,7 @@ teardown() {
279279
@test "py2.7 can package flask with slim option" {
280280
cd tests/base
281281
npm i $(npm pack ../..)
282-
sls --runtime=python2.7 --slim=true package
282+
sls --runtime=python2.7 --slim=true package
283283
unzip .serverless/sls-py-req-test.zip -d puck
284284
ls puck/flask
285285
test $(find puck -name "*.pyc" | wc -l) -eq 0
@@ -301,7 +301,7 @@ teardown() {
301301
unzip .serverless/sls-py-req-test.zip -d puck
302302
ls puck/flask
303303
test $(find puck -name "*.pyc" | wc -l) -eq 0
304-
test $(find puck -type d -name "*.egg-info*" | wc -l) -eq 0
304+
test $(find puck -type d -name "*.egg-info*" | wc -l) -eq 0
305305
}
306306

307307
@test "py2.7 doesn't package boto3 by default" {
@@ -372,7 +372,7 @@ teardown() {
372372
unzip .serverless/sls-py-req-test.zip -d puck
373373
ls puck/flask
374374
test $(find puck -name "*.pyc" | wc -l) -eq 0
375-
test $(find puck -type d -name "*.egg-info*" | wc -l) -eq 0
375+
test $(find puck -type d -name "*.egg-info*" | wc -l) -eq 0
376376
}
377377

378378
@test "pipenv py3.6 can package flask with default options" {
@@ -400,7 +400,7 @@ teardown() {
400400
unzip .serverless/sls-py-req-test.zip -d puck
401401
ls puck/flask
402402
test $(find puck -name "*.pyc" | wc -l) -eq 0
403-
test $(find puck -type d -name "*.egg-info*" | wc -l) -eq 0
403+
test $(find puck -type d -name "*.egg-info*" | wc -l) -eq 0
404404
}
405405

406406
@test "pipenv py3.6 can package flask with zip option" {

0 commit comments

Comments
 (0)