Skip to content
This repository was archived by the owner on Jan 15, 2023. It is now read-only.

Commit a94337a

Browse files
committed
Add python3.8 runtime
1 parent e358485 commit a94337a

File tree

11 files changed

+96
-7
lines changed

11 files changed

+96
-7
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ docker run --rm -v "$PWD":/var/task lambci/lambda:python2.7
7878
# Test on Python 3.6 with a custom file named my_module.py containing a my_handler function
7979
docker run --rm -v "$PWD":/var/task lambci/lambda:python3.6 my_module.my_handler
8080

81-
# Python 3.7 requires the handler be given explicitly
81+
# Python 3.7/3.8 require the handler be given explicitly
8282
docker run --rm -v "$PWD":/var/task lambci/lambda:python3.7 lambda_function.lambda_handler
8383

8484
# Similarly with Ruby 2.5
@@ -204,6 +204,7 @@ These follow the Lambda runtime names:
204204
- `python2.7`
205205
- `python3.6`
206206
- `python3.7`
207+
- `python3.8`
207208
- `ruby2.5`
208209
- `java8`
209210
- `go1.x`
@@ -218,6 +219,7 @@ These follow the Lambda runtime names:
218219
- `build-python2.7`
219220
- `build-python3.6`
220221
- `build-python3.7`
222+
- `build-python3.8`
221223
- `build-ruby2.5`
222224
- `build-java8`
223225
- `build-go1.x`

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="provided go1.x nodejs4.3 nodejs6.10 nodejs8.10 nodejs10.x nodejs12.x python2.7 python3.6 python3.7 ruby2.5 java8 dotnetcore2.0 dotnetcore2.1"
3+
RUNTIMES="provided go1.x nodejs4.3 nodejs6.10 nodejs8.10 nodejs10.x nodejs12.x python2.7 python3.6 python3.7 python3.8 ruby2.5 java8 dotnetcore2.0 dotnetcore2.1"
44

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

base/diff-2.sh

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

3-
RUNTIMES="nodejs10.x nodejs12.x"
3+
RUNTIMES="nodejs10.x nodejs12.x python3.8"
44

55
rm -rf diff-2
66
mkdir -p diff-2
@@ -45,3 +45,9 @@ pwd
4545
diff docker/var/runtime lambda/var/runtime
4646
diff -qr docker lambda
4747
echo
48+
49+
cd ${DIFF_DIR}/python3.8
50+
pwd
51+
diff docker/var/runtime lambda/var/runtime
52+
diff -qr docker lambda
53+
echo

base/dump-python38.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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']]).decode('utf-8'))
16+
17+
filename = 'python3.8.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',
25+
f'fs/{filename}', extra_args={'ACL': 'public-read'})
26+
27+
print('Uploading done!')
28+
29+
info = {'sys.executable': sys.executable,
30+
'sys.argv': sys.argv,
31+
'sys.path': sys.path,
32+
'os.getcwd': os.getcwd(),
33+
'__file__': __file__,
34+
'os.environ': {k: str(v) for k, v in os.environ.items()},
35+
'context': {k: str(v) for k, v in context.__dict__.items()},
36+
'proc environ': subprocess.check_output(
37+
['sh', '-c', 'echo /proc/1/environ; xargs -n 1 -0 < /proc/1/environ']).decode('utf-8').splitlines(),
38+
'ps aux': subprocess.check_output(
39+
['bash', '-O', 'extglob', '-c', 'for cmd in /proc/+([0-9])/cmdline; do echo $cmd; xargs -n 1 -0 < $cmd; done']).decode('utf-8').splitlines()}
40+
41+
print(json.dumps(info, indent=2))
42+
43+
return info

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="provided go1.x nodejs4.3 nodejs6.10 nodejs8.10 nodejs10.x nodejs12.x python2.7 python3.6 python3.7 ruby2.5 java8 dotnetcore2.0 dotnetcore2.1"
3+
RUNTIMES="provided go1.x nodejs4.3 nodejs6.10 nodejs8.10 nodejs10.x nodejs12.x python2.7 python3.6 python3.7 python3.8 ruby2.5 java8 dotnetcore2.0 dotnetcore2.1"
44

55
echo -n "Enter repository passphrase: "
66
read -s DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE

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="provided go1.x nodejs4.3 nodejs6.10 nodejs8.10 nodejs10.x nodejs12.x python2.7 python3.6 python3.7 ruby2.5 java8 dotnetcore2.0 dotnetcore2.1"
3+
RUNTIMES="provided go1.x nodejs4.3 nodejs6.10 nodejs8.10 nodejs10.x nodejs12.x python2.7 python3.6 python3.7 python3.8 ruby2.5 java8 dotnetcore2.0 dotnetcore2.1"
44

55
git tag -f latest
66

base/test-all.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ cd ${EXAMPLES_DIR}/python
2020
docker run --rm -v "$PWD":/var/task lambci/lambda:python2.7
2121
docker run --rm -v "$PWD":/var/task lambci/lambda:python3.6
2222
docker run --rm -v "$PWD":/var/task lambci/lambda:python3.7 lambda_function.lambda_handler
23+
docker run --rm -v "$PWD":/var/task lambci/lambda:python3.8 lambda_function.lambda_handler
2324

2425
docker run --rm -it lambci/lambda:build-python2.7 pip install marisa-trie
2526
docker run --rm -it lambci/lambda:build-python3.6 pip install marisa-trie
2627
docker run --rm -it lambci/lambda:build-python3.7 pip install marisa-trie
28+
docker run --rm -it lambci/lambda:build-python3.8 pip install marisa-trie
2729

2830
cd ${EXAMPLES_DIR}/ruby
2931
docker run --rm -v "$PWD":/var/task lambci/lambda:ruby2.5 lambda_function.lambda_handler

examples/python/lambda_function.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,5 @@ def lambda_handler(event, context):
2929
"__file__": str(__file__),
3030
"os.environ": str(os.environ),
3131
"context.__dict__": str(context.__dict__),
32-
"ps aux": str(subprocess.check_output(['ps', 'aux'])),
3332
"event": event
3433
}

nodejs12.x/run/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ COPY --from=1 /var/runtime/init /var/rapid/init
1818

1919
USER sbx_user1051
2020

21-
ENTRYPOINT ["/var/rapid/init", "--bootstrap", "/var/runtime/bootstrap"]
21+
ENTRYPOINT ["/var/rapid/init", "--bootstrap", "/var/runtime/bootstrap", "--enable-msg-logs"]

python3.8/build/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM lambci/lambda-base-2:build
2+
3+
ENV PATH=/var/lang/bin:$PATH \
4+
LD_LIBRARY_PATH=/var/lang/lib:$LD_LIBRARY_PATH \
5+
AWS_EXECUTION_ENV=AWS_Lambda_python3.8 \
6+
PYTHONPATH=/var/runtime \
7+
PKG_CONFIG_PATH=/var/lang/lib/pkgconfig:/usr/lib64/pkgconfig:/usr/share/pkgconfig
8+
9+
RUN rm -rf /var/runtime /var/lang /var/rapid && \
10+
curl https://lambci.s3.amazonaws.com/fs/python3.8.tgz | tar -zx -C /
11+
12+
# Add these as a separate layer as they get updated frequently
13+
RUN pip install -U pip setuptools --no-cache-dir && \
14+
pip install -U virtualenv pipenv --no-cache-dir && \
15+
pip install -U awscli boto3 aws-sam-cli==0.31.0 aws-lambda-builders==0.5.0 --no-cache-dir

python3.8/run/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM lambci/lambda-base
2+
3+
RUN curl https://lambci.s3.amazonaws.com/fs/python3.8.tgz | tar -zx -C /opt
4+
5+
6+
FROM lambci/lambda:provided
7+
8+
9+
FROM lambci/lambda-base-2
10+
11+
ENV PATH=/var/lang/bin:$PATH \
12+
LD_LIBRARY_PATH=/var/lang/lib:$LD_LIBRARY_PATH \
13+
AWS_EXECUTION_ENV=AWS_Lambda_python3.8
14+
15+
COPY --from=0 /opt/* /var/
16+
17+
COPY --from=1 /var/runtime/init /var/rapid/init
18+
19+
USER sbx_user1051
20+
21+
ENTRYPOINT ["/var/rapid/init", "--bootstrap", "/var/runtime/bootstrap", "--enable-msg-logs"]
22+

0 commit comments

Comments
 (0)