Skip to content

Commit 2862c0d

Browse files
author
bweigel
committed
merge master
1 parent 97417fe commit 2862c0d

File tree

5 files changed

+198
-130
lines changed

5 files changed

+198
-130
lines changed

README.md

Lines changed: 36 additions & 17 deletions
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

Lines changed: 3 additions & 0 deletions
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)

0 commit comments

Comments
 (0)