Skip to content

Commit cd525ed

Browse files
CASSANDRA-20997: Support Python 3.12 and 3.13 in cqlsh by vendoring pyasyncore
1 parent 42f306b commit cd525ed

5 files changed

Lines changed: 49 additions & 9 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/ubuntu-test.docker

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,21 @@ 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
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 2
6064
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.11 3
65+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.12 4
66+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.13 5
6167
RUN python3.8 -m pip install --upgrade pip
6268

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

102108
# 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
109+
# setup the virtualenv for the cassandra user, not root) for Python 3.8-3.13
104110
# Don't build cython extensions when installing cassandra-driver. During test execution the driver
105111
# dependency is refreshed via pip install --upgrade, so that driver changes can be pulled in without
106112
# requiring the image to be rebuilt. Rebuilding compiled extensions is costly and is disabled by
@@ -117,6 +123,16 @@ RUN /bin/bash -c "export CASS_DRIVER_NO_CYTHON=1 CASS_DRIVER_NO_EXTENSIONS=1 \
117123
&& pip3 install -r /opt/requirements.txt \
118124
&& pip3 freeze --user"
119125

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

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

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

.jenkins/Jenkinsfile

Lines changed: 2 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()

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)

0 commit comments

Comments
 (0)