Skip to content

Commit

Permalink
feat: add support for Python 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-prindle committed Feb 15, 2023
1 parent 7c11fe8 commit 3fd9ce5
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 3 deletions.
15 changes: 12 additions & 3 deletions python/helper-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

# This Dockerfile creates a debug helper base image for Python.
# It provides installations of debugpy, ptvsd, pydevd, and pydevd-pycharm
# for Python 2.7, 3.5, 3.6, 3.7, 3.8, 3.9, and 3.10.
# for Python 2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, and 3.11.
# - Apache Beam is based around Python 3.5
# - Many ML/NLP images are based on Python 3.5 and 3.6
#
# debugpy and ptvsd are well-structured packages installed in separate
# directories under # /dbg/python/lib/pythonX.Y/site-packages and
# directories under # /dbg/python/lib/pythonX.Y/site-packages
# that do not interfere with each other.
#
# pydevd and pydevd-pycharm install a script in .../bin and both install
Expand All @@ -29,7 +29,7 @@

FROM python:2.7 as python27
RUN PYTHONUSERBASE=/dbgpy pip install --user ptvsd debugpy
RUN PYTHONUSERBASE=/dbgpy/pydevd/python2.7 pip install --user pydevd --no-warn-script-location
RUN PYTHONUSERBASE=/dbgpy/pydevd/python2.7 pip install --user pydevd==2.8.0 --no-warn-script-location
COPY pydevd.patch .
RUN patch -p0 -d /dbgpy/pydevd/python2.7/lib/python2.7/site-packages < pydevd.patch
RUN PYTHONUSERBASE=/dbgpy/pydevd-pycharm/python2.7 pip install --user pydevd-pycharm --no-warn-script-location
Expand Down Expand Up @@ -76,6 +76,14 @@ COPY pydevd.patch .
RUN patch -p0 -d /dbgpy/pydevd/python3.10/lib/python3.10/site-packages < pydevd.patch
RUN PYTHONUSERBASE=/dbgpy/pydevd-pycharm/python3.10 pip install --user pydevd-pycharm --no-warn-script-location

FROM python:3.11 as python3_11
RUN PYTHONUSERBASE=/dbgpy pip install --user ptvsd debugpy
RUN PYTHONUSERBASE=/dbgpy/pydevd/python3.11 pip install --user pydevd --no-warn-script-location
COPY pydevd.patch .
RUN patch -p0 -d /dbgpy/pydevd/python3.11/lib/python3.11/site-packages < pydevd.patch
RUN PYTHONUSERBASE=/dbgpy/pydevd-pycharm/python3.11 pip install --user pydevd-pycharm --no-warn-script-location


FROM --platform=$BUILDPLATFORM golang:1.17 as build
ARG BUILDPLATFORM
ARG TARGETOS
Expand All @@ -101,4 +109,5 @@ COPY --from=python37 /dbgpy/ python/
COPY --from=python38 /dbgpy/ python/
COPY --from=python39 /dbgpy/ python/
COPY --from=python3_10 /dbgpy/ python/
COPY --from=python3_11 /dbgpy/ python/
COPY --from=build /go/launcher python/
9 changes: 9 additions & 0 deletions python/skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ profiles:
docker:
buildArgs:
PYTHONVERSION: "3.10"
- op: add
path: /build/artifacts/-
value:
image: python311app
context: test/pythonapp
docker:
buildArgs:
PYTHONVERSION: "3.11"
- op: add
path: /build/artifacts/-
value:
Expand All @@ -70,6 +78,7 @@ profiles:
manifests:
- test/k8s-test-pydevd-python39.yaml
- test/k8s-test-pydevd-python310.yaml
- test/k8s-test-pydevd-python311.yaml

# release: pushes images to production with :latest
- name: release
Expand Down
9 changes: 9 additions & 0 deletions python/structure-tests-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ fileExistenceTests:
- name: 'pydevd-pycharm for python 3.10'
path: '/duct-tape/python/pydevd-pycharm/python3.10/lib/python3.10/site-packages/pydevd.py'

- name: 'ptvsd for python 3.11'
path: '/duct-tape/python/lib/python3.11/site-packages/ptvsd/__init__.py'
- name: 'debugpy for python 3.11'
path: '/duct-tape/python/lib/python3.11/site-packages/debugpy/__init__.py'
- name: 'pydevd for python 3.11'
path: '/duct-tape/python/pydevd/python3.11/lib/python3.11/site-packages/pydevd.py'
- name: 'pydevd-pycharm for python 3.11'
path: '/duct-tape/python/pydevd-pycharm/python3.11/lib/python3.11/site-packages/pydevd.py'

- name: 'python launcher'
path: '/duct-tape/python/launcher'
isExecutableBy: any
Expand Down
77 changes: 77 additions & 0 deletions python/test/k8s-test-pydevd-python311.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
apiVersion: v1
kind: Pod
metadata:
name: python311pod
labels:
app: hello
protocol: pydevd
runtime: python311
spec:
containers:
- name: python311app
image: python311app
command: ["/dbg/python/launcher", "--mode", "pydevd", "--port", "12345", "--"]
args: ["python", "-m", "flask", "run", "--host=0.0.0.0"]
ports:
- containerPort: 5000
- containerPort: 12345
name: pydevd
env:
- name: WRAPPER_VERBOSE
value: debug
readinessProbe:
httpGet:
path: /
port: 5000
volumeMounts:
- mountPath: /dbg
name: python-debugging-support
initContainers:
- image: skaffold-debug-python
name: install-python-support
resources: {}
volumeMounts:
- mountPath: /dbg
name: python-debugging-support
volumes:
- emptyDir: {}
name: python-debugging-support

---
apiVersion: v1
kind: Service
metadata:
name: hello-pydevd-python311
spec:
ports:
- name: http
port: 5000
protocol: TCP
- name: pydevd
port: 12345
protocol: TCP
selector:
app: hello
protocol: pydevd
runtime: python311

---
apiVersion: batch/v1
kind: Job
metadata:
name: connect-to-python311
labels:
project: container-debug-support
type: integration-test
spec:
ttlSecondsAfterFinished: 10
backoffLimit: 1
template:
spec:
restartPolicy: Never
containers:
- name: verify-python311
image: pydevconnect
args: ["hello-pydevd-python311:12345"]


0 comments on commit 3fd9ce5

Please sign in to comment.