From 3fd9ce57ed0f2fdd8fb09c43937ce9a1e8c123bf Mon Sep 17 00:00:00 2001 From: Aaron Prindle Date: Sun, 18 Dec 2022 01:10:02 +0000 Subject: [PATCH] feat: add support for Python 3.11 --- python/helper-image/Dockerfile | 15 ++++- python/skaffold.yaml | 9 +++ python/structure-tests-python.yaml | 9 +++ python/test/k8s-test-pydevd-python311.yaml | 77 ++++++++++++++++++++++ 4 files changed, 107 insertions(+), 3 deletions(-) create mode 100644 python/test/k8s-test-pydevd-python311.yaml diff --git a/python/helper-image/Dockerfile b/python/helper-image/Dockerfile index 104441e5..7c1f2423 100644 --- a/python/helper-image/Dockerfile +++ b/python/helper-image/Dockerfile @@ -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 @@ -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 @@ -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 @@ -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/ diff --git a/python/skaffold.yaml b/python/skaffold.yaml index 094c74f1..faf3f1d2 100644 --- a/python/skaffold.yaml +++ b/python/skaffold.yaml @@ -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: @@ -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 diff --git a/python/structure-tests-python.yaml b/python/structure-tests-python.yaml index 801f548a..3a97f15a 100644 --- a/python/structure-tests-python.yaml +++ b/python/structure-tests-python.yaml @@ -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 diff --git a/python/test/k8s-test-pydevd-python311.yaml b/python/test/k8s-test-pydevd-python311.yaml new file mode 100644 index 00000000..ab56df96 --- /dev/null +++ b/python/test/k8s-test-pydevd-python311.yaml @@ -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"] + +