Skip to content

Commit 5e1bded

Browse files
authored
Add Python 3.10 runtime based on Python 3.9 runtime. (#128)
1 parent 29065c9 commit 5e1bded

File tree

9 files changed

+157
-3
lines changed

9 files changed

+157
-3
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ deploy:
4545
all_branches: true
4646
repo: apache/openwhisk-runtime-python
4747
- provider: script
48-
script: "./tools/travis/publish.sh openwhisk 3 nightly && ./tools/travis/publish.sh openwhisk 3-ai nightly && ./tools/travis/publish.sh openwhisk 39 nightly"
48+
script: "./tools/travis/publish.sh openwhisk 3 nightly && ./tools/travis/publish.sh openwhisk 3-ai nightly && ./tools/travis/publish.sh openwhisk 39 nightly && ./tools/travis/publish.sh openwhisk 310 nightly"
4949
on:
5050
branch: master
5151
repo: apache/openwhisk-runtime-python

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ The following Python runtime versions (with kind & image labels) are generated b
2727

2828
- Python 3.7 (python:3.7 & openwhisk/action-python-v3.7)
2929
- Python 3.9 (python:3.9 & openwhisk/action-python-v3.9)
30+
- Python 3.10 (python:3.10 & openwhisk/action-python-v3.10)
3031
- Python 3.6 AI (python:3.6 & openwhisk/action-python-v3.6-ai)
3132

3233
This README documents the build, customization and testing of these runtime images.
@@ -152,6 +153,6 @@ If you have an action in the format described before (with a `requirements.txt`)
152153
zip -j -r myaction | docker run -i action-python-v3.7 -compile main > myaction.zip
153154
```
154155

155-
You may use `v3.9` or `v3.6-ai` as well according to your Python version needs.
156+
You may use `v3.10`, `v3.9` or `v3.6-ai` as well according to your Python version needs.
156157

157158
The resulting action includes a virtualenv already built for you and that is fast to deploy and start as all the dependencies are already resolved. Note that there is a limit on the size of the zip file and this approach will not work for installing large libraries like Pandas or Numpy, instead use the provide "v.3.6-ai" runtime instead which provides these libraries already for you.

core/python310Action/Dockerfile

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
# build go proxy from source
19+
FROM golang:1.18 AS builder_source
20+
ARG GO_PROXY_GITHUB_USER=apache
21+
ARG GO_PROXY_GITHUB_BRANCH=master
22+
RUN git clone --branch ${GO_PROXY_GITHUB_BRANCH} \
23+
https://github.com/${GO_PROXY_GITHUB_USER}/openwhisk-runtime-go /src ;\
24+
cd /src ; env GO111MODULE=on CGO_ENABLED=0 go build main/proxy.go && \
25+
mv proxy /bin/proxy
26+
27+
# or build it from a release
28+
FROM golang:1.18 AS builder_release
29+
ARG GO_PROXY_RELEASE_VERSION=1.18@1.19.0
30+
RUN curl -sL \
31+
https://github.com/apache/openwhisk-runtime-go/archive/{$GO_PROXY_RELEASE_VERSION}.tar.gz\
32+
| tar xzf -\
33+
&& cd openwhisk-runtime-go-*/main\
34+
&& GO111MODULE=on go build -o /bin/proxy
35+
36+
FROM python:3.10-buster
37+
38+
# select the builder to use
39+
ARG GO_PROXY_BUILD_FROM=release
40+
41+
# install zip
42+
RUN apt-get update && apt-get install -y zip \
43+
&& rm -rf /var/lib/apt/lists/*
44+
45+
# Install common modules for python
46+
COPY requirements_common.txt requirements_common.txt
47+
COPY requirements.txt requirements.txt
48+
RUN pip3 install --upgrade pip six wheel &&\
49+
pip3 install --no-cache-dir -r requirements.txt
50+
51+
RUN mkdir -p /action
52+
WORKDIR /
53+
54+
COPY --from=builder_source /bin/proxy /bin/proxy_source
55+
COPY --from=builder_release /bin/proxy /bin/proxy_release
56+
RUN mv /bin/proxy_${GO_PROXY_BUILD_FROM} /bin/proxy
57+
58+
ADD bin/compile /bin/compile
59+
ADD lib/launcher.py /lib/launcher.py
60+
61+
# log initialization errors
62+
ENV OW_LOG_INIT_ERROR=1
63+
# the launcher must wait for an ack
64+
ENV OW_WAIT_FOR_ACK=1
65+
# using the runtime name to identify the execution environment
66+
ENV OW_EXECUTION_ENV=openwhisk/action-python-v3.10
67+
# compiler script
68+
ENV OW_COMPILER=/bin/compile
69+
70+
ENTRYPOINT ["/bin/proxy"]

core/python310Action/build.gradle

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
ext.dockerImageName = 'action-python-v3.10'
19+
apply from: '../../gradle/docker.gradle'
20+
21+
distDocker.dependsOn 'copyLib'
22+
distDocker.dependsOn 'copyBin'
23+
distDocker.dependsOn 'copyReqrCommon'
24+
distDocker.finalizedBy('cleanup')
25+
26+
task copyLib(type: Copy) {
27+
from '../python3Action/lib'
28+
into './lib'
29+
}
30+
31+
task copyBin(type: Copy) {
32+
from '../python3Action/bin'
33+
into './bin'
34+
}
35+
36+
task copyReqrCommon(type: Copy) {
37+
from '../requirements_common.txt'
38+
into './'
39+
}
40+
41+
task cleanup(type: Delete) {
42+
delete 'bin'
43+
delete 'lib'
44+
delete 'requirements_common.txt'
45+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# default packages available for action-python-v3.10
2+
-r requirements_common.txt

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ include 'tests'
2020
include 'core:python3Action'
2121
include 'core:python36AiAction'
2222
include 'core:python39Action'
23+
include 'core:python310Action'
2324

2425
rootProject.name = 'runtime-python'
2526

tests/src/test/resources/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if [ -f ".built" ]; then
2121
exit 0
2222
fi
2323

24-
for i in v3.7 v3.6-ai v3.9
24+
for i in v3.7 v3.6-ai v3.9 v3.10
2525
do echo "*** $i ***"
2626
zip -r -j - python_virtualenv | docker run -i action-python-$i -compile main >python-${i}_virtualenv.zip
2727
cp python-${i}_virtualenv.zip python-${i}_virtualenv_invalid_main.zip
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package runtime.actionContainers
19+
20+
import org.junit.runner.RunWith
21+
import org.scalatest.junit.JUnitRunner
22+
23+
@RunWith(classOf[JUnitRunner])
24+
class Python310Tests extends Python37Tests {
25+
26+
override lazy val imageName = "action-python-v3.10"
27+
28+
override lazy val zipPrefix = "python-v3.10"
29+
30+
override lazy val errorCodeOnRun = false
31+
32+
override val testNoSource = TestConfig("", hasCodeStub = false)
33+
}

tools/travis/publish.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ elif [ ${RUNTIME_VERSION} == "3-ai" ]; then
3636
RUNTIME="python36AiAction"
3737
elif [ ${RUNTIME_VERSION} == "39" ]; then
3838
RUNTIME="python39Action"
39+
elif [ ${RUNTIME_VERSION} == "310" ]; then
40+
RUNTIME="python310Action"
3941
fi
4042

4143
if [[ ! -z ${DOCKER_USER} ]] && [[ ! -z ${DOCKER_PASSWORD} ]]; then

0 commit comments

Comments
 (0)