From d8c3ca33fd9bfaccae6a68a4e10009aefb0536c0 Mon Sep 17 00:00:00 2001 From: arvindksi274-ksolves Date: Fri, 20 Feb 2026 14:01:00 +0530 Subject: [PATCH] CASSANDRA-20997: Support Python 3.12 and 3.13 in cqlsh by vendoring pyasyncore --- .build/build-resolver.xml | 2 ++ .build/docker/ubuntu-test.docker | 42 ++++++++++++++++++++++++++++++-- .jenkins/Jenkinsfile | 4 +-- bin/cqlsh | 4 +-- bin/cqlsh.py | 6 ++--- 5 files changed, 49 insertions(+), 9 deletions(-) diff --git a/.build/build-resolver.xml b/.build/build-resolver.xml index 7e88a4ee73..aa248ddf4e 100644 --- a/.build/build-resolver.xml +++ b/.build/build-resolver.xml @@ -245,6 +245,7 @@ + @@ -261,6 +262,7 @@ + diff --git a/.build/docker/ubuntu-test.docker b/.build/docker/ubuntu-test.docker index 6eadf55e25..2c52ec94e3 100644 --- a/.build/docker/ubuntu-test.docker +++ b/.build/docker/ubuntu-test.docker @@ -49,15 +49,21 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ apt-get update && \ apt-get install -y curl git-core python3-pip \ python3.8 python3.8-venv python3.8-dev \ + python3.10 python3.10-venv python3.10-dev \ python3.11 python3.11-venv python3.11-dev \ + python3.12 python3.12-venv python3.12-dev \ + python3.13 python3.13-venv python3.13-dev \ virtualenv net-tools libev4 libev-dev wget gcc libxml2 libxslt1-dev \ vim lsof sudo libjemalloc2 dumb-init locales rsync \ openjdk-8-jdk openjdk-11-jdk openjdk-17-jdk openjdk-21-jdk ant ant-optional RUN update-alternatives --remove java /usr/lib/jvm/java-8-openjdk-$(dpkg --print-architecture)/jre/bin/java RUN update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-8-openjdk-$(dpkg --print-architecture)/bin/java 1081 -RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.8 2 +RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1 +RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.10 2 RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.11 3 +RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.12 4 +RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.13 5 RUN python3.8 -m pip install --upgrade pip # generate locales for the standard en_US.UTF8 value we use for testing @@ -101,7 +107,7 @@ RUN bash /tmp/_prepopulate_maven_deps.sh /home/image-cache/.m2/repository RUN cp -a /home/cassandra-tmp/.gradle /home/image-cache/.gradle # run pip commands and setup virtualenv (note we do this after we switch to cassandra user so we -# setup the virtualenv for the cassandra user and not the root user by accident) for Python 3.8/3.11 +# setup the virtualenv for the cassandra user, not root) for Python 3.8-3.13 # Don't build cython extensions when installing cassandra-driver. During test execution the driver # dependency is refreshed via pip install --upgrade, so that driver changes can be pulled in without # requiring the image to be rebuilt. Rebuilding compiled extensions is costly and is disabled by @@ -118,6 +124,16 @@ RUN /bin/bash -c "export CASS_DRIVER_NO_CYTHON=1 CASS_DRIVER_NO_EXTENSIONS=1 \ && pip3 install -r /opt/requirements.txt \ && pip3 freeze --user" +RUN virtualenv --python=python3.10 ${BUILD_HOME}/env3.10 +RUN chmod +x ${BUILD_HOME}/env3.10/bin/activate + +RUN /bin/bash -c "export CASS_DRIVER_NO_CYTHON=1 CASS_DRIVER_NO_EXTENSIONS=1 \ + && source ${BUILD_HOME}/env3.10/bin/activate \ + && curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10 \ + && pip3 install --upgrade \"pip<25.0\" \"setuptools==60.8.2\" wheel \ + && pip3 install --no-build-isolation -r /opt/requirements.txt \ + && pip3 freeze --user" + RUN python3.11 -m venv ${BUILD_HOME}/env3.11 RUN chmod +x ${BUILD_HOME}/env3.11/bin/activate @@ -128,6 +144,28 @@ RUN /bin/bash -c "export CASS_DRIVER_NO_CYTHON=1 CASS_DRIVER_NO_EXTENSIONS=1 \ && pip3 install --no-build-isolation -r /opt/requirements.txt \ && pip3 freeze --user" +RUN virtualenv --python=python3.12 ${BUILD_HOME}/env3.12 +RUN chmod +x ${BUILD_HOME}/env3.12/bin/activate + +RUN /bin/bash -c "export CASS_DRIVER_NO_CYTHON=1 CASS_DRIVER_NO_EXTENSIONS=1 \ + && source ${BUILD_HOME}/env3.12/bin/activate \ + && curl -sS https://bootstrap.pypa.io/get-pip.py | python3.12 \ + && pip3 install --upgrade \"pip<25.0\" \"setuptools>=65.5.0,<70.0.0\" wheel \ + && sed -i 's/pkgutil.ImpImporter/type(\"ImpImporter\", (object,), {})/g' ${BUILD_HOME}/env3.12/lib/python3.12/site-packages/pkg_resources/__init__.py \ + && pip3 install --no-build-isolation -r /opt/requirements.txt \ + && pip3 freeze --user" + +RUN virtualenv --python=python3.13 ${BUILD_HOME}/env3.13 +RUN chmod +x ${BUILD_HOME}/env3.13/bin/activate + +RUN /bin/bash -c "export CASS_DRIVER_NO_CYTHON=1 CASS_DRIVER_NO_EXTENSIONS=1 \ + && source ${BUILD_HOME}/env3.13/bin/activate \ + && curl -sS https://bootstrap.pypa.io/get-pip.py | python3.13 \ + && pip3 install --upgrade \"pip<25.0\" \"setuptools>=65.5.0,<70.0.0\" wheel \ + && sed -i 's/pkgutil.ImpImporter/type(\"ImpImporter\", (object,), {})/g' ${BUILD_HOME}/env3.13/lib/python3.13/site-packages/pkg_resources/__init__.py \ + && pip3 install --no-build-isolation -r /opt/requirements.txt \ + && pip3 freeze --user" + # 4* requires java8, sudo doesn't work on cross-platform builds USER root RUN update-alternatives --set java /usr/lib/jvm/java-8-openjdk-$(dpkg --print-architecture)/bin/java diff --git a/.jenkins/Jenkinsfile b/.jenkins/Jenkinsfile index ea412aca0f..e478240973 100644 --- a/.jenkins/Jenkinsfile +++ b/.jenkins/Jenkinsfile @@ -59,7 +59,7 @@ /** CONSTANTS for both the pipeline and scripting **/ import groovy.transform.Field @Field List archsSupported = ["amd64", "arm64"] -@Field List pythonsSupported = ["3.8", "3.11"] +@Field List pythonsSupported = ["3.8", "3.11", "3.12", "3.13"] @Field String pythonDefault = "3.8" /** CONSTANTS end **********************************/ @@ -124,7 +124,7 @@ pipeline { } post { failure { - echo "ERROR pipeline failed – not all tests were run" + echo "ERROR pipeline failed – not all tests were run" } always { sendNotifications() diff --git a/bin/cqlsh b/bin/cqlsh index 2a9651968b..25fa029b4f 100755 --- a/bin/cqlsh +++ b/bin/cqlsh @@ -63,7 +63,7 @@ is_supported_version() { major_version="${version%.*}" minor_version="${version#*.}" # python 3.8-3.11 are supported - if [ "$major_version" = 3 ] && [ "$minor_version" -ge 8 ] && [ "$minor_version" -le 11 ]; then + if [ "$major_version" = 3 ] && [ "$minor_version" -ge 8 ] && [ "$minor_version" -le 13 ]; then echo "supported" # python 3.6-3.7 are deprecated elif [ "$major_version" = 3 ] && [ "$minor_version" -ge 6 ] && [ "$minor_version" -le 7 ]; then @@ -88,7 +88,7 @@ run_if_supported_version() { exec "$interpreter" "$($interpreter -c "import os; print(os.path.dirname(os.path.realpath('$0')))")/cqlsh.py" "$@" exit else - echo "Warning: unsupported version of Python, required 3.6-3.11 but found" "$version" >&2 + echo "Warning: unsupported version of Python, required 3.6-3.13 but found" "$version" >&2 fi fi } diff --git a/bin/cqlsh.py b/bin/cqlsh.py index 738f0aeeb7..5131f99062 100755 --- a/bin/cqlsh.py +++ b/bin/cqlsh.py @@ -21,8 +21,8 @@ import platform import sys from glob import glob -if sys.version_info < (3, 6) or sys.version_info >= (3, 12): - sys.exit("\ncqlsh requires Python 3.6-3.11\n") +if sys.version_info < (3, 6) or sys.version_info >= (3, 14): + sys.exit("\ncqlsh requires Python 3.6-3.13\n") # see CASSANDRA-10428 if platform.python_implementation().startswith('Jython'): @@ -56,7 +56,7 @@ if cql_zip: sys.path.insert(0, os.path.join(cql_zip, 'cassandra-driver-' + ver)) # the driver needs dependencies -third_parties = ('pure_sasl-', 'wcwidth-') +third_parties = ('pure_sasl-', 'wcwidth-', 'pyasyncore-') for lib in third_parties: lib_zip = find_zip(lib)