FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add python3.7 runtime · forkkit/docker-lambda@113c2dd · GitHub

Commit 113c2dd

Browse files
committed
Add python3.7 runtime
1 parent 98c67ee commit 113c2dd

12 files changed

Lines changed: 206 additions & 37 deletions

File tree

‎README.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ docker run --rm -v "$PWD":/var/task lambci/lambda:python2.7
6060
# Test on Python 3.6 with a custom file named my_module.py containing a my_handler function
6161
docker run --rm -v "$PWD":/var/task lambci/lambda:python3.6 my_module.my_handler
6262

63+
# Python 3.7 requires the handler be given explicitly
64+
docker run --rm -v "$PWD":/var/task lambci/lambda:python3.7 lambda_function.lambda_handler
65+
6366
# Test on Go 1.x with a compiled handler named my_handler and a custom event
6467
docker run --rm -v "$PWD":/var/task lambci/lambda:go1.x my_handler '{"some": "event"}'
6568

@@ -204,6 +207,7 @@ Docker tags (follow the Lambda runtime names):
204207
- `nodejs8.10`
205208
- `python2.7`
206209
- `python3.6`
210+
- `python3.7`
207211
- `java8`
208212
- `go1.x`
209213
- `dotnetcore2.0`
@@ -214,6 +218,7 @@ Docker tags (follow the Lambda runtime names):
214218
- `build-nodejs8.10`
215219
- `build-python2.7`
216220
- `build-python3.6`
221+
- `build-python3.7`
217222
- `build-java8`
218223
- `build-go1.x`
219224
- `build-dotnetcore2.0`

‎base/build-all.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
RUNTIMES="nodejs4.3 nodejs6.10 nodejs8.10 python2.7 python3.6 java8 go1.x dotnetcore2.0 dotnetcore2.1 provided"
3+
RUNTIMES="nodejs4.3 nodejs6.10 nodejs8.10 python2.7 python3.6 python3.7 java8 go1.x dotnetcore2.0 dotnetcore2.1 provided"
44

55
TOP_DIR="${PWD}/.."
66

‎base/diff.sh‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
RUNTIMES="nodejs4.3 nodejs6.10 nodejs8.10 python2.7 python3.6 java8 go1.x dotnetcore2.0 dotnetcore2.1 provided"
3+
RUNTIMES="nodejs4.3 nodejs6.10 nodejs8.10 python2.7 python3.6 python3.7 java8 go1.x dotnetcore2.0 dotnetcore2.1 provided"
44

55
rm -rf diff
66
mkdir -p diff
@@ -53,6 +53,13 @@ pwd
5353
diff docker/var/runtime/awslambda/bootstrap.py lambda/var/runtime/awslambda/bootstrap.py
5454
diff -qr docker lambda | grep -v __pycache__
5555

56+
cd ${DIFF_DIR}/python3.7
57+
pwd
58+
diff docker/var/runtime/bootstrap lambda/var/runtime/bootstrap
59+
diff docker/var/runtime/bootstrap.py lambda/var/runtime/bootstrap.py
60+
diff docker/var/runtime/lambda_runtime_client.py lambda/var/runtime/lambda_runtime_client.py
61+
diff -qr docker lambda | grep -v __pycache__
62+
5663
cd ${DIFF_DIR}/java8
5764
pwd
5865
diff -qr docker lambda

‎base/dump-python36.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ def lambda_handler(event, context):
1414
if 'cmd' in event:
1515
return print(subprocess.check_output(['sh', '-c', event['cmd']]))
1616

17-
subprocess.call(['sh', '-c', 'tar -cpzf /tmp/python3.6.tgz --numeric-owner --ignore-failed-read ' +
17+
filename = 'python3.6.tgz'
18+
19+
subprocess.call(['sh', '-c', f'tar -cpzf /tmp/{filename} --numeric-owner --ignore-failed-read ' +
1820
'/var/runtime /var/lang /var/rapid'])
1921

2022
print('Zipping done! Uploading...')
2123

22-
TRANSFER.upload_file('/tmp/python3.6.tgz', 'lambci', 'fs/python3.6.tgz', extra_args={'ACL': 'public-read'})
24+
TRANSFER.upload_file(f'/tmp/{filename}', 'lambci', f'fs/{filename}', extra_args={'ACL': 'public-read'})
2325

2426
print('Uploading done!')
2527

‎base/dump-python37.py‎

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
from __future__ import print_function
2+
3+
import os
4+
import sys
5+
import subprocess
6+
import json
7+
import boto3
8+
from boto3.s3.transfer import S3Transfer
9+
10+
TRANSFER = S3Transfer(boto3.client('s3'))
11+
12+
13+
def lambda_handler(event, context):
14+
if 'cmd' in event:
15+
return print(subprocess.check_output(['sh', '-c', event['cmd']]))
16+
17+
filename = 'python3.7.tgz'
18+
19+
subprocess.call(['sh', '-c', f'tar -cpzf /tmp/{filename} --numeric-owner --ignore-failed-read ' +
20+
'/var/runtime /var/lang /var/rapid'])
21+
22+
print('Zipping done! Uploading...')
23+
24+
TRANSFER.upload_file(f'/tmp/{filename}', 'lambci', f'fs/{filename}', extra_args={'ACL': 'public-read'})
25+
26+
print('Uploading done!')
27+
28+
info = {'sys.executable': sys.executable,
29+
'sys.argv': sys.argv,
30+
'sys.path': sys.path,
31+
'os.getcwd': os.getcwd(),
32+
'__file__': __file__,
33+
'os.environ': {k: str(v) for k, v in os.environ.items()},
34+
'context': {k: str(v) for k, v in context.__dict__.items()},
35+
'ps aux': subprocess.check_output(['ps', 'aux']).decode('utf-8').splitlines(),
36+
'proc environ': subprocess.check_output(
37+
['sh', '-c', 'xargs -n 1 -0 < /proc/1/environ']).decode('utf-8').splitlines()}
38+
39+
print(json.dumps(info, indent=2))
40+
41+
return info
42+
43+
# "sys.executable": "/var/lang/bin/python3.7",
44+
# "sys.argv": [
45+
# "/var/runtime/bootstrap"
46+
# ],
47+
# "sys.path": [
48+
# "/var/task",
49+
# "/opt/python/lib/python3.7/site-packages",
50+
# "/opt/python",
51+
# "/var/runtime",
52+
# "/var/lang/lib/python37.zip",
53+
# "/var/lang/lib/python3.7",
54+
# "/var/lang/lib/python3.7/lib-dynload",
55+
# "/var/lang/lib/python3.7/site-packages",
56+
# "/opt/python/lib/python3.7/site-packages",
57+
# "/opt/python"
58+
# ],
59+
# "os.getcwd": "/var/task",
60+
# "__file__": "/var/task/lambda_function.py",
61+
# "os.environ": {
62+
# "PATH": "/var/lang/bin:/usr/local/bin:/usr/bin/:/bin:/opt/bin",
63+
# "LD_LIBRARY_PATH": "/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib",
64+
# "LANG": "en_US.UTF-8",
65+
# "TZ": ":UTC",
66+
# "LAMBDA_TASK_ROOT": "/var/task",
67+
# "LAMBDA_RUNTIME_DIR": "/var/runtime",
68+
# "AWS_REGION": "us-east-1",
69+
# "AWS_DEFAULT_REGION": "us-east-1",
70+
# "AWS_LAMBDA_LOG_GROUP_NAME": "/aws/lambda/dump-python37",
71+
# "AWS_LAMBDA_LOG_STREAM_NAME": "2018/11/20/[$LATEST]ac1dfb2ddf5a4ce8ae56fb4f8bbef79e",
72+
# "AWS_LAMBDA_FUNCTION_NAME": "dump-python37",
73+
# "AWS_LAMBDA_FUNCTION_MEMORY_SIZE": "3008",
74+
# "AWS_LAMBDA_FUNCTION_VERSION": "$LATEST",
75+
# "_AWS_XRAY_DAEMON_ADDRESS": "169.254.79.2",
76+
# "_AWS_XRAY_DAEMON_PORT": "2000",
77+
# "AWS_XRAY_DAEMON_ADDRESS": "169.254.79.2:2000",
78+
# "AWS_XRAY_CONTEXT_MISSING": "LOG_ERROR",
79+
# "AWS_EXECUTION_ENV": "AWS_Lambda_python3.7",
80+
# "_HANDLER": "lambda_function.lambda_handler",
81+
# "AWS_ACCESS_KEY_ID": "ASIAYBQ3XNZICRJLMSWK",
82+
# "AWS_SECRET_ACCESS_KEY": "zVGU...",
83+
# "AWS_SESSION_TOKEN": "FQoG...",
84+
# "_X_AMZN_TRACE_ID": "Root=1-5bf3752e-f6ac2142f8303c52aaab2628;Parent=08d2682547d140dd;Sampled=0"
85+
# },
86+
# "context": {
87+
# "aws_request_id": "475d3ab2-ec6e-11e8-acea-69ef4368db5c",
88+
# "log_group_name": "/aws/lambda/dump-python37",
89+
# "log_stream_name": "2018/11/20/[$LATEST]ac1dfb2ddf5a4ce8ae56fb4f8bbef79e",
90+
# "function_name": "dump-python37",
91+
# "memory_limit_in_mb": "3008",
92+
# "function_version": "$LATEST",
93+
# "invoked_function_arn": "arn:aws:lambda:us-east-1:999999999999:function:dump-python37",
94+
# "client_context": "None",
95+
# "identity": "<bootstrap.CognitoIdentity object at 0x7f0a8b6dbe48>",
96+
# "_epoch_deadline_time_in_ms": "1542682202288"
97+
# },
98+
# "ps aux": [
99+
# "USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND",
100+
# "473 1 0.0 0.1 205576 6896 ? Ssl 02:38 0:00 /var/rapid/init --bootstrap /var/runtime/bootstrap",
101+
# "473 7 0.0 0.7 230312 28936 ? S 02:38 0:00 /var/lang/bin/python3.7 /var/runtime/bootstrap",
102+
# "473 40 0.0 0.0 117224 2512 ? R 02:45 0:00 ps aux"
103+
# ],
104+
# "proc environ": [
105+
# "PATH=/var/lang/bin:/usr/local/bin:/usr/bin/:/bin:/opt/bin",
106+
# "LD_LIBRARY_PATH=/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib",
107+
# "LANG=en_US.UTF-8",
108+
# "TZ=:UTC",
109+
# "_LAMBDA_CONTROL_SOCKET=15",
110+
# "_LAMBDA_CONSOLE_SOCKET=17",
111+
# "LAMBDA_TASK_ROOT=/var/task",
112+
# "LAMBDA_RUNTIME_DIR=/var/runtime",
113+
# "_LAMBDA_LOG_FD=24",
114+
# "_LAMBDA_SB_ID=23",
115+
# "_LAMBDA_SHARED_MEM_FD=12",
116+
# "AWS_REGION=us-east-1",
117+
# "AWS_DEFAULT_REGION=us-east-1",
118+
# "AWS_LAMBDA_LOG_GROUP_NAME=/aws/lambda/dump-python37",
119+
# "AWS_LAMBDA_LOG_STREAM_NAME=2018/11/20/[$LATEST]ac1dfb2ddf5a4ce8ae56fb4f8bbef79e",
120+
# "AWS_LAMBDA_FUNCTION_NAME=dump-python37",
121+
# "AWS_LAMBDA_FUNCTION_MEMORY_SIZE=3008",
122+
# "AWS_LAMBDA_FUNCTION_VERSION=$LATEST",
123+
# "_AWS_XRAY_DAEMON_ADDRESS=169.254.79.2",
124+
# "_AWS_XRAY_DAEMON_PORT=2000",
125+
# "AWS_XRAY_DAEMON_ADDRESS=169.254.79.2:2000",
126+
# "AWS_XRAY_CONTEXT_MISSING=LOG_ERROR",
127+
# "_X_AMZN_TRACE_ID=Parent=22afbb5e10233b0d",
128+
# "AWS_EXECUTION_ENV=AWS_Lambda_python3.7",
129+
# "_HANDLER=lambda_function.lambda_handler",
130+
# "_LAMBDA_RUNTIME_LOAD_TIME=1534336339261"
131+
# ]

‎base/dump.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
RUNTIMES="node43 node610 node810 python27 python36 java8 go1x dotnetcore20 dotnetcore21 provided"
3+
RUNTIMES="node43 node610 node810 python27 python36 python37 java8 go1x dotnetcore20 dotnetcore21 provided"
44

55
for RUNTIME in $RUNTIMES; do
66
echo $RUNTIME

‎base/publish-all.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
RUNTIMES="nodejs4.3 nodejs6.10 nodejs8.10 python2.7 python3.6 java8 go1.x dotnetcore2.0 dotnetcore2.1 provided"
3+
RUNTIMES="nodejs4.3 nodejs6.10 nodejs8.10 python2.7 python3.6 python3.7 java8 go1.x dotnetcore2.0 dotnetcore2.1 provided"
44

55
docker push lambci/lambda-base
66

‎base/tag-all.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
RUNTIMES="nodejs4.3 nodejs6.10 nodejs8.10 python2.7 python3.6 java8 go1.x dotnetcore2.0 dotnetcore2.1 provided"
3+
RUNTIMES="nodejs4.3 nodejs6.10 nodejs8.10 python2.7 python3.6 python3.7 java8 go1.x dotnetcore2.0 dotnetcore2.1 provided"
44

55
git tag -f latest
66

‎base/test-all.sh‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ npm test
1717
cd ${EXAMPLES_DIR}/python
1818
docker run --rm -v "$PWD":/var/task lambci/lambda:python2.7
1919
docker run --rm -v "$PWD":/var/task lambci/lambda:python3.6
20+
docker run --rm -v "$PWD":/var/task lambci/lambda:python3.7 lambda_function.lambda_handler
2021

2122
cd ${EXAMPLES_DIR}/java
2223
gradle build

‎examples/python/lambda_function.py‎

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,28 @@
77
# docker run --rm -v "$PWD":/var/task lambci/lambda:python2.7
88
# OR
99
# docker run --rm -v "$PWD":/var/task lambci/lambda:python3.6
10+
# OR
11+
# docker run --rm -v "$PWD":/var/task lambci/lambda:python3.7 lambda_function.lambda_handler
1012

1113
def lambda_handler(event, context):
12-
for arg in sys.argv:
13-
print(arg)
14-
print(os.getcwd())
15-
print(os.path.basename(__file__))
16-
for key in os.environ.keys():
17-
print('{0}={1}'.format(key,os.environ[key]))
18-
print(subprocess.check_output(['ps', 'aux']).decode('utf-8'))
19-
print(subprocess.check_output(['sh', '-c', 'xargs -n 1 -0 < /proc/1/environ']).decode('utf-8'))
20-
print(sys.path)
21-
print(os.getuid())
22-
print(os.getgid())
23-
print(os.geteuid())
24-
print(os.getegid())
25-
print(os.getgroups())
26-
print(os.umask(0o222))
14+
context.log('Hello!')
15+
context.log('Hmmm, does not add newlines in 3.7?')
16+
context.log('\n')
2717

28-
print(event)
29-
print(context.get_remaining_time_in_millis())
30-
print(context.aws_request_id)
31-
if context.client_context:
32-
print(context.client_context)
33-
print(context.function_name)
34-
print(context.function_version)
35-
print(context.identity.cognito_identity_id)
36-
print(context.identity.cognito_identity_pool_id)
37-
print(context.invoked_function_arn)
38-
print(context.log('Log this for me please'))
39-
print(context.log_group_name)
40-
print(context.log_stream_name)
41-
print(context.memory_limit_in_mb)
18+
print(sys.executable)
19+
print(sys.argv)
20+
print(os.getcwd())
21+
print(__file__)
22+
print(os.environ)
23+
print(context.__dict__)
4224

43-
return 'It works!'
25+
return {
26+
"executable": str(sys.executable),
27+
"sys.argv": str(sys.argv),
28+
"os.getcwd": str(os.getcwd()),
29+
"__file__": str(__file__),
30+
"os.environ": str(os.environ),
31+
"context.__dict__": str(context.__dict__),
32+
"ps aux": str(subprocess.check_output(['ps', 'aux'])),
33+
"event": event
34+
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL