Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# npm install | ||
node_modules | ||
package-lock.json | ||
|
||
# serverless | ||
.serverless | ||
.requirements.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
### native compilation example | ||
Uses `dockerizePip` to deploy numpy-scipy-sklearn demo. | ||
|
||
### test | ||
As in other examples, use node version >= 6. | ||
|
||
``` | ||
cd example_native_deps | ||
npm install --prefix . serverless-python-requirements | ||
sls deploy --verbose | ||
sls invoke -f hello --verbose --log | ||
``` | ||
|
||
...expected result: | ||
|
||
``` | ||
{ | ||
"numpy": "1.13.3", | ||
"scipy": "1.0.0", | ||
"sklearn": "0.19.1" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# must be called as we're using zipped requirements | ||
try: | ||
import unzip_requirements | ||
except ImportError: | ||
pass | ||
|
||
import numpy | ||
import scipy | ||
import sklearn | ||
|
||
|
||
def hello(event, context): | ||
return {mod.__name__: mod.__version__ for mod in (numpy, scipy, sklearn)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
numpy==1.13.3 | ||
scipy==1.0.0 | ||
sklearn==0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
service: sls-py-req-test | ||
|
||
provider: | ||
name: aws | ||
runtime: python3.6 | ||
|
||
plugins: | ||
- serverless-python-requirements | ||
|
||
custom: | ||
pythonRequirements: | ||
# call `pip install` inside a container - useful for packages that have native dependencies (scipy et-al) | ||
dockerizePip: true | ||
|
||
# aws lambda has an after-extraction size limit - with native dependencies we pass the limit quickly | ||
# zip the requirements and extract them on the fly (see handler.py) | ||
zip: true | ||
|
||
package: | ||
# exclude everything... | ||
exclude: | ||
- '**/*' | ||
|
||
# include - we have to explicitly list packages with native dependencies. | ||
include: | ||
- '*.py' | ||
- 'numpy' | ||
- 'scipy' | ||
|
||
functions: | ||
hello: | ||
handler: handler.hello |