Skip to content

Commit 8a4eb7d

Browse files
Add Python 3.12 (#152)
* Add Python 3.12 * downgrade twisted for scrapy * downgrade twisted for scrapy: The user requested twisted==23.8.0 scrapy 2.11.0 depends on Twisted<23.8.0 and >=18.9.0 * downgrade twisted for scrapy: The user requested twisted==22.8.0 * Update core/python312Action/Dockerfile Co-authored-by: David Grove <dgrove-oss@users.noreply.github.com> * Update core/python312Action/requirements.txt Co-authored-by: David Grove <dgrove-oss@users.noreply.github.com> --------- Co-authored-by: David Grove <dgrove-oss@users.noreply.github.com>
1 parent c0a1e6d commit 8a4eb7d

File tree

8 files changed

+170
-1
lines changed

8 files changed

+170
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ jobs:
9696
./gradlew :core:python310Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=$SHORT_COMMIT
9797
./gradlew :core:python311Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=nightly
9898
./gradlew :core:python311Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=$SHORT_COMMIT
99+
./gradlew :core:python312Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=nightly
100+
./gradlew :core:python312Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=$SHORT_COMMIT
99101
- name: Push Release Images
100102
if: ${{ env.PUSH_RELEASE == 'true' }}
101103
working-directory: runtime
@@ -108,5 +110,7 @@ jobs:
108110
RUNTIME="python310Action"
109111
elif [ ${RUNTIME_VERSION} == "311" ]; then
110112
RUNTIME="python311Action"
113+
elif [ ${RUNTIME_VERSION} == "312" ]; then
114+
RUNTIME="python312Action"
111115
fi
112116
./gradlew :core:$RUNTIME:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=$IMAGE_TAG

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ The following Python runtime versions (with kind & image labels) are generated b
2828
- Python 3.9 (python:3.9 & openwhisk/action-python-v3.9)
2929
- Python 3.10 (python:3.10 & openwhisk/action-python-v3.10)
3030
- Python 3.11 (python:3.11 & openwhisk/action-python-v3.11)
31+
- Python 3.12 (python:3.12 & openwhisk/action-python-v3.12)
3132

3233
This README documents the build, customization and testing of these runtime images.
3334

core/python312Action/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.21 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.21 AS builder_release
29+
ARG GO_PROXY_RELEASE_VERSION=1.21@1.23.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 CGO_ENABLED=0 go build -o /bin/proxy
35+
36+
FROM python:3.12-bookworm
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 gcc \
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.12
67+
# compiler script
68+
ENV OW_COMPILER=/bin/compile
69+
70+
ENTRYPOINT ["/bin/proxy"]

core/python312Action/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.12'
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: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# default packages available for action-python-v3.12
2+
#-r requirements_common.txt
3+
beautifulsoup4==4.12.3
4+
httplib2==0.22.0
5+
kafka_python==2.0.2
6+
lxml==5.1.0
7+
python-dateutil==2.8.2
8+
requests==2.31.0
9+
scrapy==2.11.0
10+
simplejson==3.19.2
11+
virtualenv==20.25.0
12+
twisted==22.8.0
13+
netifaces==0.11.0
14+
# fix issue: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools
15+
setuptools == 69.0.3

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:python39Action'
2121
include 'core:python310Action'
2222
include 'core:python311Action'
23+
include 'core:python312Action'
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.9 v3.10 v3.11
24+
for i in v3.9 v3.10 v3.11 v3.12
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 Python312Tests extends Python3Tests {
25+
26+
override lazy val imageName = "action-python-v3.12"
27+
28+
override lazy val zipPrefix = "python-v3.12"
29+
30+
override lazy val errorCodeOnRun = false
31+
32+
override val testNoSource = TestConfig("", hasCodeStub = false)
33+
}

0 commit comments

Comments
 (0)