Skip to content

Commit 464b2e5

Browse files
arvindKandpal-ksolvessmiklosovic
authored andcommitted
Support Python 3.12 and 3.13 in cqlsh
patch by Arvind Kandpal; reviewed by Stefan Miklosovic, Michael Semb Wever for CASSANDRA-20997
1 parent 448d98c commit 464b2e5

11 files changed

Lines changed: 67 additions & 12 deletions

File tree

.build/build-resolver.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@
247247
<file file="${local.repository}/org/apache/cassandra/deps/geomet-0.1.0.zip"/>
248248
<file file="${local.repository}/org/apache/cassandra/deps/pure_sasl-0.6.2-py2-none-any.zip"/>
249249
<file file="${local.repository}/org/apache/cassandra/deps/wcwidth-0.2.5-py2.py3-none-any.zip"/>
250+
<file file="${local.repository}/org/apache/cassandra/deps/pyasyncore-1.0.5-py3-none-any.zip"/>
250251
</copy>
251252
<copy todir="${build.lib}/sigar-bin/" quiet="true">
252253
<file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-amd64-freebsd-6.so"/>
@@ -284,6 +285,7 @@
284285
<get src="${artifact.python.pypi}/59/a0/cf4cd997e1750f0c2d91c6ea5abea218251c43c3581bcc2f118b00baf5cf/futures-2.1.6-py2.py3-none-any.whl" dest="${local.repository}/org/apache/cassandra/deps/futures-2.1.6-py2.py3-none-any.zip" usetimestamp="true" quiet="true" skipexisting="true"/>
285286
<get src="${artifact.python.pypi}/37/b2/ef1124540ee2c0b417be8d0f74667957e6aa084a3f26621aa67e2e77f3fb/pure_sasl-0.6.2-py2-none-any.whl" dest="${local.repository}/org/apache/cassandra/deps/pure_sasl-0.6.2-py2-none-any.zip" usetimestamp="true" quiet="true" skipexisting="true"/>
286287
<get src="${artifact.python.pypi}/59/7c/e39aca596badaf1b78e8f547c807b04dae603a433d3e7a7e04d67f2ef3e5/wcwidth-0.2.5-py2.py3-none-any.whl" dest="${local.repository}/org/apache/cassandra/deps/wcwidth-0.2.5-py2.py3-none-any.zip" usetimestamp="true" quiet="true" skipexisting="true"/>
288+
<get src="${artifact.python.pypi}/1f/ab/b10cee56269ae150763f3f83b3e9305a11f42f50b3dcd58eeb8f7988f0bb/pyasyncore-1.0.5-py3-none-any.whl" dest="${local.repository}/org/apache/cassandra/deps/pyasyncore-1.0.5-py3-none-any.zip" usetimestamp="true" quiet="true" skipexisting="true"/>
287289

288290
<!-- apache/cassandra/lib -->
289291
<get src="${lib.download.base.url}/lib/geomet-0.1.0.zip" dest="${local.repository}/org/apache/cassandra/deps/geomet-0.1.0.zip" usetimestamp="true" quiet="true" skipexisting="true"/>

.build/docker/run-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ echo "Running container ${container_name} ${docker_id} using image ${image_name}
300300

301301
docker exec --user root ${container_name} bash -c "\${CASSANDRA_DIR}/.build/docker/_create_user.sh cassandra $(id -u) $(id -g)" | tee -a ${logfile}
302302
docker exec --user root ${container_name} update-alternatives --set python /usr/bin/python${python_version} | tee -a ${logfile}
303+
docker exec --user root ${container_name} update-alternatives --set python3 /usr/bin/python${python_version} | tee -a ${logfile}
303304

304305
if [ -n "${DTEST_TMPDIR_LOCAL}" ] && [[ "${target}" =~ ^dtest-upgrade ]] ; then
305306
# prepopulate a tmp ccm repository directory, if running dtest-upgrade tests

.build/docker/ubuntu-test.docker

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,26 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
4949
apt-get update && \
5050
apt-get install -y curl git-core python3-pip \
5151
python3.8 python3.8-venv python3.8-dev \
52+
python3.10 python3.10-venv python3.10-dev \
5253
python3.11 python3.11-venv python3.11-dev \
54+
python3.12 python3.12-venv python3.12-dev \
55+
python3.13 python3.13-venv python3.13-dev \
5356
virtualenv net-tools libev4 libev-dev wget gcc libxml2 libxslt1-dev \
5457
vim lsof sudo libjemalloc2 dumb-init locales rsync \
5558
openjdk-8-jdk openjdk-11-jdk openjdk-17-jdk ant ant-optional
5659

5760
RUN update-alternatives --remove java /usr/lib/jvm/java-8-openjdk-$(dpkg --print-architecture)/jre/bin/java
5861
RUN update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-8-openjdk-$(dpkg --print-architecture)/bin/java 1081
59-
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.8 2
60-
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.11 3
62+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
63+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1
64+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1
65+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.12 1
66+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.13 1
67+
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
68+
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
69+
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1
70+
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1
71+
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.13 1
6172
RUN python3.8 -m pip install --upgrade pip
6273

6374
# generate locales for the standard en_US.UTF8 value we use for testing
@@ -100,7 +111,7 @@ RUN bash /tmp/_prepopulate_maven_deps.sh /home/image-cache/.m2/repository
100111
RUN cp -a /home/cassandra-tmp/.gradle /home/image-cache/.gradle
101112

102113
# run pip commands and setup virtualenv (note we do this after we switch to cassandra user so we
103-
# setup the virtualenv for the cassandra user and not the root user by accident) for Python 3.8/3.11
114+
# setup the virtualenv for the cassandra user, not root) for Python 3.8-3.13
104115
# Don't build cython extensions when installing cassandra-driver. During test execution the driver
105116
# dependency is refreshed via pip install --upgrade, so that driver changes can be pulled in without
106117
# requiring the image to be rebuilt. Rebuilding compiled extensions is costly and is disabled by
@@ -117,6 +128,16 @@ RUN /bin/bash -c "export CASS_DRIVER_NO_CYTHON=1 CASS_DRIVER_NO_EXTENSIONS=1 \
117128
&& pip3 install -r /opt/requirements.txt \
118129
&& pip3 freeze --user"
119130

131+
RUN virtualenv --python=python3.10 ${BUILD_HOME}/env3.10
132+
RUN chmod +x ${BUILD_HOME}/env3.10/bin/activate
133+
134+
RUN /bin/bash -c "export CASS_DRIVER_NO_CYTHON=1 CASS_DRIVER_NO_EXTENSIONS=1 \
135+
&& source ${BUILD_HOME}/env3.10/bin/activate \
136+
&& curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10 \
137+
&& pip3 install --upgrade \"pip<25.0\" \"setuptools==60.8.2\" wheel \
138+
&& pip3 install --no-build-isolation -r /opt/requirements.txt \
139+
&& pip3 freeze --user"
140+
120141
RUN python3.11 -m venv ${BUILD_HOME}/env3.11
121142
RUN chmod +x ${BUILD_HOME}/env3.11/bin/activate
122143

@@ -127,6 +148,28 @@ RUN /bin/bash -c "export CASS_DRIVER_NO_CYTHON=1 CASS_DRIVER_NO_EXTENSIONS=1 \
127148
&& pip3 install --no-build-isolation -r /opt/requirements.txt \
128149
&& pip3 freeze --user"
129150

151+
RUN virtualenv --python=python3.12 ${BUILD_HOME}/env3.12
152+
RUN chmod +x ${BUILD_HOME}/env3.12/bin/activate
153+
154+
RUN /bin/bash -c "export CASS_DRIVER_NO_CYTHON=1 CASS_DRIVER_NO_EXTENSIONS=1 \
155+
&& source ${BUILD_HOME}/env3.12/bin/activate \
156+
&& curl -sS https://bootstrap.pypa.io/get-pip.py | python3.12 \
157+
&& pip3 install --upgrade \"pip<25.0\" \"setuptools>=65.5.0,<70.0.0\" wheel \
158+
&& sed -i 's/pkgutil.ImpImporter/type(\"ImpImporter\", (object,), {})/g' ${BUILD_HOME}/env3.12/lib/python3.12/site-packages/pkg_resources/__init__.py \
159+
&& pip3 install --no-build-isolation -r /opt/requirements.txt \
160+
&& pip3 freeze --user"
161+
162+
RUN virtualenv --python=python3.13 ${BUILD_HOME}/env3.13
163+
RUN chmod +x ${BUILD_HOME}/env3.13/bin/activate
164+
165+
RUN /bin/bash -c "export CASS_DRIVER_NO_CYTHON=1 CASS_DRIVER_NO_EXTENSIONS=1 \
166+
&& source ${BUILD_HOME}/env3.13/bin/activate \
167+
&& curl -sS https://bootstrap.pypa.io/get-pip.py | python3.13 \
168+
&& pip3 install --upgrade \"pip<25.0\" \"setuptools>=65.5.0,<70.0.0\" wheel \
169+
&& sed -i 's/pkgutil.ImpImporter/type(\"ImpImporter\", (object,), {})/g' ${BUILD_HOME}/env3.13/lib/python3.13/site-packages/pkg_resources/__init__.py \
170+
&& pip3 install --no-build-isolation -r /opt/requirements.txt \
171+
&& pip3 freeze --user"
172+
130173
# 4* requires java8, sudo doesn't work on cross-platform builds
131174
USER root
132175
RUN update-alternatives --set java /usr/lib/jvm/java-8-openjdk-$(dpkg --print-architecture)/bin/java

.build/run-tests.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
set -o errexit
2525
set -o pipefail
2626

27-
[ $DEBUG ] && set -x
28-
2927
# variables, with defaults
3028
[ "x${CASSANDRA_DIR}" != "x" ] || CASSANDRA_DIR="$(readlink -f $(dirname -- "$0")/..)"
3129
[ "x${DIST_DIR}" != "x" ] || DIST_DIR="${CASSANDRA_DIR}/build"

.jenkins/Jenkinsfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
/** CONSTANTS for both the pipeline and scripting **/
6060
import groovy.transform.Field
6161
@Field List<String> archsSupported = ["amd64", "arm64"]
62-
@Field List<String> pythonsSupported = ["3.8", "3.11"]
62+
@Field List<String> pythonsSupported = ["3.8", "3.11", "3.12", "3.13"]
6363
@Field String pythonDefault = "3.8"
6464
/** CONSTANTS end **********************************/
6565

@@ -124,7 +124,7 @@ pipeline {
124124
}
125125
post {
126126
failure {
127-
echo "ERROR pipeline failed – not all tests were run"
127+
echo "ERROR pipeline failed – not all tests were run"
128128
}
129129
always {
130130
sendNotifications()
@@ -254,6 +254,7 @@ def tasks() {
254254
(isStageEnabled(axis['step'])) && // skip disabled steps
255255
!(axis['python'] != pythonDefault && 'cqlsh-test' != axis['step']) && // Use only python 3.8 for all tests but cqlsh-test
256256
!(axis['cython'] != 'no' && 'cqlsh-test' != axis['step']) && // cython only for cqlsh-test, disable for others
257+
!(axis['cython'] == 'yes' && (axis['python'] == '3.12' || axis['python'] == '3.13')) && // Skip cython for Python 3.12+ see CASSANDRA-21482
257258
!(axis['jdk'] != javaVersionDefault && ('cqlsh-test' == axis['step'] || 'simulator-dtest' == axis['step'] || axis['step'].contains('dtest-upgrade'))) && // run cqlsh-test, simulator-dtest, *dtest-upgrade only with jdk11
258259
// Disable splits for all but proper stages
259260
!(axis['split'] > 1 && !stepsMap.findAll { entry -> entry.value.splits >= axis['split'] }.keySet().contains(axis['step'])) &&

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
5.0.9
2+
* Support Python 3.12 and 3.13 in cqlsh (CASSANDRA-20997)
23
* Fix AssertionError in hasReplicaWithOngoingRepair when parallel_repair_count > 1 (CASSANDRA-21426)
34
* putShortVolatile is not volatile in InMemoryTrie (CASSANDRA-21353)
45
* Fix RequestFailureReason serializer and nits in a few others (CASSANDRA-21437)

bin/cqlsh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ is_supported_version() {
6363
major_version="${version%.*}"
6464
minor_version="${version#*.}"
6565
# python 3.8-3.11 are supported
66-
if [ "$major_version" = 3 ] && [ "$minor_version" -ge 8 ] && [ "$minor_version" -le 11 ]; then
66+
if [ "$major_version" = 3 ] && [ "$minor_version" -ge 8 ] && [ "$minor_version" -le 13 ]; then
6767
echo "supported"
6868
# python 3.6-3.7 are deprecated
6969
elif [ "$major_version" = 3 ] && [ "$minor_version" -ge 6 ] && [ "$minor_version" -le 7 ]; then
@@ -88,7 +88,7 @@ run_if_supported_version() {
8888
exec "$interpreter" "$($interpreter -c "import os; print(os.path.dirname(os.path.realpath('$0')))")/cqlsh.py" "$@"
8989
exit
9090
else
91-
echo "Warning: unsupported version of Python, required 3.6-3.11 but found" "$version" >&2
91+
echo "Warning: unsupported version of Python, required 3.6-3.13 but found" "$version" >&2
9292
fi
9393
fi
9494
}

bin/cqlsh.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import sys
2222
from glob import glob
2323

24-
if sys.version_info < (3, 6) or sys.version_info >= (3, 12):
25-
sys.exit("\ncqlsh requires Python 3.6-3.11\n")
24+
if sys.version_info < (3, 6) or sys.version_info >= (3, 14):
25+
sys.exit("\ncqlsh requires Python 3.6-3.13\n")
2626

2727
# see CASSANDRA-10428
2828
if platform.python_implementation().startswith('Jython'):
@@ -56,7 +56,7 @@ def find_zip(libprefix):
5656
sys.path.insert(0, os.path.join(cql_zip, 'cassandra-driver-' + ver))
5757

5858
# the driver needs dependencies
59-
third_parties = ('pure_sasl-', 'wcwidth-')
59+
third_parties = ('pure_sasl-', 'wcwidth-', 'pyasyncore-')
6060

6161
for lib in third_parties:
6262
lib_zip = find_zip(lib)

pylib/cassandra-cqlsh-tests.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#
2424
################################
2525

26+
[ $DEBUG ] && set -x
27+
2628
WORKSPACE=$1
2729

2830
[ "x${WORKSPACE}" != "x" ] || WORKSPACE="$(readlink -f $(dirname "$0")/..)"
@@ -63,6 +65,10 @@ rm -fr ${DIST_DIR}/venv ${DIST_DIR}/test/{html,output,logs}
6365
virtualenv-clone ${BUILD_HOME}/env${python_version} ${BUILD_DIR}/venv || virtualenv --python=python3 ${BUILD_DIR}/venv
6466
source ${BUILD_DIR}/venv/bin/activate
6567

68+
# Force pip's legacy pkg_resources metadata backend (instead of the importlib.metadata
69+
# backend that pip defaults to on Python 3.11+). see ubuntu-test.docker
70+
export _PIP_USE_IMPORTLIB_METADATA=0
71+
6672
pip install --exists-action w -r ${CASSANDRA_DIR}/pylib/requirements.txt
6773
pip freeze
6874

pylib/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@
2323
coverage
2424
pytest
2525
wcwidth
26+
pyasyncore

0 commit comments

Comments
 (0)