Skip to content

Commit 12e32d4

Browse files
authored
feat: add support for python 3.10 (#101)
1 parent 002c195 commit 12e32d4

File tree

5 files changed

+114
-7
lines changed

5 files changed

+114
-7
lines changed

python/helper-image/Dockerfile

+18-6
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
# This Dockerfile creates a debug helper base image for Python.
1616
# It provides installations of debugpy, ptvsd, pydevd, and pydevd-pycharm
17-
# for Python 2.7, 3.5, 3.6, 3.7, 3.8, and 3.9.
17+
# for Python 2.7, 3.5, 3.6, 3.7, 3.8, 3.9, and 3.10.
1818
# - Apache Beam is based around Python 3.5
19-
# - Many ML/NLP images are based on Python 3.6
19+
# - Many ML/NLP images are based on Python 3.5 and 3.6
2020
#
2121
# debugpy and ptvsd are well-structured packages installed in separate
2222
# directories under # /dbg/python/lib/pythonX.Y/site-packages and
@@ -69,15 +69,26 @@ COPY pydevd.patch .
6969
RUN patch -p0 -d /dbgpy/pydevd/python3.9/lib/python3.9/site-packages < pydevd.patch
7070
RUN PYTHONUSERBASE=/dbgpy/pydevd-pycharm/python3.9 pip install --user pydevd-pycharm --no-warn-script-location
7171

72-
FROM golang:1.17 as build
72+
FROM python:3.10 as python3_10
73+
RUN PYTHONUSERBASE=/dbgpy pip install --user ptvsd debugpy
74+
RUN PYTHONUSERBASE=/dbgpy/pydevd/python3.10 pip install --user pydevd --no-warn-script-location
75+
COPY pydevd.patch .
76+
RUN patch -p0 -d /dbgpy/pydevd/python3.10/lib/python3.10/site-packages < pydevd.patch
77+
RUN PYTHONUSERBASE=/dbgpy/pydevd-pycharm/python3.10 pip install --user pydevd-pycharm --no-warn-script-location
78+
79+
FROM --platform=$BUILDPLATFORM golang:1.17 as build
80+
ARG BUILDPLATFORM
81+
ARG TARGETOS
82+
ARG TARGETARCH
7383
COPY launcher/ .
7484
# Produce an as-static-as-possible wrapper binary to work on musl and glibc
75-
RUN GOPATH="" CGO_ENABLED=0 go build -o launcher -ldflags '-s -w -extldflags "-static"' .
85+
RUN GOPATH="" CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
86+
go build -o launcher -ldflags '-s -w -extldflags "-static"' .
7687

7788
# Now populate the duct-tape image with the language runtime debugging support files
7889
# The debian image is about 95MB bigger
79-
FROM busybox
80-
ARG BUILDPLATFORM
90+
FROM --platform=$TARGETPLATFORM busybox
91+
ARG TARGETPLATFORM
8192

8293
# The install script copies all files in /duct-tape to /dbg
8394
COPY install.sh /
@@ -89,4 +100,5 @@ COPY --from=python36 /dbgpy/ python/
89100
COPY --from=python37 /dbgpy/ python/
90101
COPY --from=python38 /dbgpy/ python/
91102
COPY --from=python39 /dbgpy/ python/
103+
COPY --from=python3_10 /dbgpy/ python/
92104
COPY --from=build /go/launcher python/

python/skaffold.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ profiles:
5252
docker:
5353
buildArgs:
5454
PYTHONVERSION: "3.9"
55+
- op: add
56+
path: /build/artifacts/-
57+
value:
58+
image: python310app
59+
context: test/pythonapp
60+
docker:
61+
buildArgs:
62+
PYTHONVERSION: "3.10"
5563
- op: add
5664
path: /build/artifacts/-
5765
value:
@@ -61,6 +69,7 @@ profiles:
6169
kubectl:
6270
manifests:
6371
- test/k8s-test-pydevd-python39.yaml
72+
- test/k8s-test-pydevd-python310.yaml
6473

6574
# release: pushes images to production with :latest
6675
- name: release

python/structure-tests-python.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ fileExistenceTests:
5555
- name: 'pydevd-pycharm for python 3.9'
5656
path: '/duct-tape/python/pydevd-pycharm/python3.9/lib/python3.9/site-packages/pydevd.py'
5757

58+
- name: 'ptvsd for python 3.10'
59+
path: '/duct-tape/python/lib/python3.10/site-packages/ptvsd/__init__.py'
60+
- name: 'debugpy for python 3.10'
61+
path: '/duct-tape/python/lib/python3.10/site-packages/debugpy/__init__.py'
62+
- name: 'pydevd for python 3.10'
63+
path: '/duct-tape/python/pydevd/python3.10/lib/python3.10/site-packages/pydevd.py'
64+
- name: 'pydevd-pycharm for python 3.10'
65+
path: '/duct-tape/python/pydevd-pycharm/python3.10/lib/python3.10/site-packages/pydevd.py'
66+
5867
- name: 'python launcher'
5968
path: '/duct-tape/python/launcher'
6069
isExecutableBy: any
+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: python310pod
5+
labels:
6+
app: hello
7+
protocol: pydevd
8+
runtime: python310
9+
spec:
10+
containers:
11+
- name: python310app
12+
image: python310app
13+
command: ["/dbg/python/launcher", "--mode", "pydevd", "--port", "12345", "--"]
14+
args: ["python", "-m", "flask", "run", "--host=0.0.0.0"]
15+
ports:
16+
- containerPort: 5000
17+
- containerPort: 12345
18+
name: pydevd
19+
env:
20+
- name: WRAPPER_VERBOSE
21+
value: debug
22+
readinessProbe:
23+
httpGet:
24+
path: /
25+
port: 5000
26+
volumeMounts:
27+
- mountPath: /dbg
28+
name: python-debugging-support
29+
initContainers:
30+
- image: skaffold-debug-python
31+
name: install-python-support
32+
resources: {}
33+
volumeMounts:
34+
- mountPath: /dbg
35+
name: python-debugging-support
36+
volumes:
37+
- emptyDir: {}
38+
name: python-debugging-support
39+
40+
---
41+
apiVersion: v1
42+
kind: Service
43+
metadata:
44+
name: hello-pydevd-python310
45+
spec:
46+
ports:
47+
- name: http
48+
port: 5000
49+
protocol: TCP
50+
- name: pydevd
51+
port: 12345
52+
protocol: TCP
53+
selector:
54+
app: hello
55+
protocol: pydevd
56+
runtime: python310
57+
58+
---
59+
apiVersion: batch/v1
60+
kind: Job
61+
metadata:
62+
name: connect-to-python310
63+
labels:
64+
project: container-debug-support
65+
type: integration-test
66+
spec:
67+
ttlSecondsAfterFinished: 10
68+
backoffLimit: 1
69+
template:
70+
spec:
71+
restartPolicy: Never
72+
containers:
73+
- name: verify-python310
74+
image: pydevconnect
75+
args: ["hello-pydevd-python310:12345"]
76+
77+

run-its.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ while [ $jobcount -eq 0 -o $jobcount -ne $(countTestJobs) ]; do
3333
done
3434

3535
echo ">> Monitoring for test job completion [$(date)]"
36-
kubectl wait --for=condition=complete job.batch \
36+
kubectl wait --for=condition=complete job.batch --timeout=120s \
3737
-l project=container-debug-support,type=integration-test

0 commit comments

Comments
 (0)