Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .build/build-resolver.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@

<!-- files.pythonhosted.org -->
<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"/>
<get src="${artifact.python.pypi}/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl" dest="${local.repository}/org/apache/cassandra/deps/six-1.12.0-py2.py3-none-any.zip" usetimestamp="true" quiet="true" skipexisting="true"/>
<get src="${artifact.python.pypi}/20/f4/c0584a25144ce20bfcf1aecd041768b8c762c1eb0aa77502a3f0baa83f11/wcwidth-0.2.6-py2.py3-none-any.whl" dest="${local.repository}/org/apache/cassandra/deps/wcwidth-0.2.6-py2.py3-none-any.zip" usetimestamp="true" quiet="true" skipexisting="true"/>
<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"/>

Expand Down Expand Up @@ -239,7 +238,6 @@

<copy todir="${build.lib}" quiet="true">
<file file="${local.repository}/org/apache/cassandra/deps/futures-2.1.6-py2.py3-none-any.zip"/>
<file file="${local.repository}/org/apache/cassandra/deps/six-1.12.0-py2.py3-none-any.zip"/>
<file file="${local.repository}/org/apache/cassandra/deps/geomet-0.1.0.zip"/>
<file file="${local.repository}/org/apache/cassandra/deps/wcwidth-0.2.6-py2.py3-none-any.zip"/>
<file file="${local.repository}/org/apache/cassandra/deps/pure_sasl-0.6.2-py2-none-any.zip"/>
Expand Down
2 changes: 1 addition & 1 deletion README.asc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ For more information, see http://cassandra.apache.org/[the Apache Cassandra web
Requirements
------------
. Java >= 1.8 (OpenJDK and Oracle JVMS have been tested)
. Python 3.6+ (for cqlsh; 2.7 works but is deprecated)
. Python 3.8+ (for cqlsh)

Getting started
---------------
Expand Down
6 changes: 4 additions & 2 deletions bin/cqlsh
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ is_supported_version() {
version=$1
major_version="${version%.*}"
minor_version="${version#*.}"
# python3.6+ is supported. python2.7 is deprecated but still compatible.
if [ "$major_version" = 3 ] && [ "$minor_version" -ge 6 ] || [ "$version" = "2.7" ]; then
# python 3.8-3.12 is supported
if [ "$major_version" = 3 ] && [ "$minor_version" -ge 8 ] && [ "$minor_version" -le 12 ]; then
echo "supported"
else
echo "unsupported"
Expand All @@ -79,6 +79,8 @@ run_if_supported_version() {
if [ "$(is_supported_version "$version")" = "supported" ]; then
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.8-3.12 but found" $version >&2
fi
fi
}
Expand Down
54 changes: 20 additions & 34 deletions bin/cqlsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
from glob import glob
from uuid import UUID

if sys.version_info < (3, 6) and sys.version_info[0:2] != (2, 7):
sys.exit("\ncqlsh requires Python 3.6+ or Python 2.7 (deprecated)\n")
if sys.version_info < (3, 8) or sys.version_info > (3, 12):
sys.exit("\ncqlsh requires Python 3.8-3.12\n")

# see CASSANDRA-10428
if platform.python_implementation().startswith('Jython'):
Expand Down Expand Up @@ -117,19 +117,15 @@ def find_zip(libprefix):
sys.path.insert(0, os.path.join(cql_zip, 'cassandra-driver-' + ver))

# the driver needs dependencies
third_parties = ('futures-', 'six-', 'geomet-', 'pure_sasl-', 'datastax_db_*-')
third_parties = ('geomet-', 'pure_sasl-', 'datastax_db_*-')

for lib in third_parties:
lib_zip = find_zip(lib)
if lib_zip:
sys.path.insert(0, lib_zip)

# We cannot import six until we add its location to sys.path so the Python
# interpreter can find it. Do not move this to the top.
import six

from six.moves import configparser, input
from six import StringIO, ensure_text, ensure_str
import configparser
from io import StringIO

warnings.filterwarnings("ignore", r".*blist.*")
try:
Expand Down Expand Up @@ -369,7 +365,7 @@ def __repr__(self):


def maybe_ensure_text(val):
return ensure_text(val) if val else val
return str(val) if val else val


class FormatError(DecodeError):
Expand Down Expand Up @@ -434,7 +430,7 @@ def deserialize_date_fallback_int(byts, protocol_version):


class Shell(cmd.Cmd):
custom_prompt = ensure_text(os.getenv('CQLSH_PROMPT', ''))
custom_prompt = os.getenv('CQLSH_PROMPT', '')
if custom_prompt != '':
custom_prompt += "\n"
default_prompt = custom_prompt + "cqlsh> "
Expand Down Expand Up @@ -576,7 +572,6 @@ def __init__(self, hostname, port, color=False,

if tty:
self.reset_prompt()
self.maybe_warn_py2()
self.report_connection()
print('Use HELP for help.')
else:
Expand Down Expand Up @@ -661,12 +656,6 @@ def show_version(self):
vers['cql'] = self.cql_version
print("[cqlsh %(shver)s | Cassandra %(build)s | CQL spec %(cql)s | Native protocol v%(protocol)s]" % vers)

def maybe_warn_py2(self):
py2_suppress_warn = 'CQLSH_NO_WARN_PY2'
if sys.version_info[0:2] == (2, 7) and not os.environ.get(py2_suppress_warn):
print("Python 2.7 support is deprecated. "
"Install Python 3.6+ or set %s to suppress this message.\n" % (py2_suppress_warn,))

def show_session(self, sessionid, partial_session=False):
print_trace_session(self, self.tracing_style, self.session, sessionid, partial_session)

Expand Down Expand Up @@ -915,15 +904,14 @@ def prepare_loop(self):

def get_input_line(self, prompt=''):
if self.tty:
self.lastcmd = input(ensure_str(prompt))
line = ensure_text(self.lastcmd) + '\n'
self.lastcmd = input(str(prompt))
line = self.lastcmd + '\n'
else:
self.lastcmd = ensure_text(self.stdin.readline())
self.lastcmd = self.stdin.readline()
line = self.lastcmd
if not len(line):
raise EOFError
self.lineno += 1
line = ensure_text(line)
return line

def use_stdin_reader(self, until='', prompt=''):
Expand Down Expand Up @@ -984,7 +972,6 @@ def onecmd(self, statementtext):
Returns true if the statement is complete and was handled (meaning it
can be reset).
"""
statementtext = ensure_text(statementtext)
statementtext = self.strip_comment_blocks(statementtext)
try:
statements, endtoken_escaped = cqlruleset.cql_split_statements(statementtext)
Expand Down Expand Up @@ -1030,7 +1017,7 @@ def handle_statement(self, tokens, srcstr):
if readline is not None:
nl_count = srcstr.count("\n")

new_hist = ensure_str(srcstr.replace("\n", " ").rstrip())
new_hist = srcstr.replace("\n", " ").rstrip()

if nl_count > 1 and self.last_hist != new_hist:
readline.add_history(new_hist)
Expand Down Expand Up @@ -1081,7 +1068,6 @@ def do_select(self, parsed):
self.tracing_style = tracing_was_enabled

def perform_statement(self, statement):
statement = ensure_text(statement)

stmt = SimpleStatement(statement, consistency_level=self.consistency_level, serial_consistency_level=self.serial_consistency_level, fetch_size=self.page_size if self.use_paging else None)
success, future = self.perform_simple_statement(stmt)
Expand Down Expand Up @@ -1133,7 +1119,7 @@ def perform_simple_statement(self, statement):
return False, None

def print_cql_error(err):
err_msg = ensure_text(err.message if hasattr(err, 'message') else str(err))
err_msg = err.message if hasattr(err, 'message') else str(err)
self.printerr(str(err.__class__.__name__) + ": " + err_msg)

future = self.session.execute_async(statement, trace=self.tracing_style in ["full", "compact"])
Expand Down Expand Up @@ -1466,7 +1452,7 @@ def do_describe(self, parsed):
self.describe_element(result)

except CQL_ERRORS as err:
err_msg = ensure_text(err.message if hasattr(err, 'message') else str(err))
err_msg = err.message if hasattr(err, 'message') else str(err)
self.printerr(err_msg.partition("message=")[2].strip('"'))
except Exception:
import traceback
Expand All @@ -1482,7 +1468,7 @@ def describe_keyspaces(self, rows):
"""
Print the output for a DESCRIBE KEYSPACES query
"""
names = [ensure_str(r['name']) for r in rows]
names = [r['name'] for r in rows]

print('')
cmd.Cmd.columnize(self, names)
Expand All @@ -1502,7 +1488,7 @@ def describe_list(self, rows):
keyspace = row['keyspace_name']
names = list()

names.append(ensure_str(row['name']))
names.append(str(row['name']))

if keyspace is not None:
self.print_keyspace_element_names(keyspace, names)
Expand Down Expand Up @@ -1644,7 +1630,7 @@ def do_copy(self, parsed):
if fname is not None:
fname = self.cql_unprotect_value(fname)

copyoptnames = list(map(six.text_type.lower, parsed.get_binding('optnames', ())))
copyoptnames = list(map(str.lower, parsed.get_binding('optnames', ())))
copyoptvals = list(map(self.cql_unprotect_value, parsed.get_binding('optvals', ())))
opts = dict(list(zip(copyoptnames, copyoptvals)))

Expand Down Expand Up @@ -2105,11 +2091,11 @@ def writeresult(self, text, color=None, newline=True, out=None):
out = self.query_out

# convert Exceptions, etc to text
if not isinstance(text, six.text_type):
text = "{}".format(text)
if not isinstance(text, str):
text = str(text)

to_write = self.applycolor(text, color) + ('\n' if newline else '')
to_write = ensure_str(to_write)
to_write = str(to_write)
out.write(to_write)

def flush_output(self):
Expand Down Expand Up @@ -2227,7 +2213,7 @@ def should_use_color():


def read_options(cmdlineargs, environment):
configs = configparser.SafeConfigParser() if sys.version_info < (3, 2) else configparser.ConfigParser()
configs = configparser.ConfigParser()
configs.read(CONFIG_FILE)

rawconfigs = configparser.RawConfigParser()
Expand Down
3 changes: 1 addition & 2 deletions doc/modules/cassandra/pages/getting_started/installing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ verify that you have the correct version of java installed, type
Full support is effective Cassandra 4.0.2 version (https://issues.apache.org/jira/browse/CASSANDRA-16894[CASSANDRA-16894])
For more information, see
https://github.com/apache/cassandra/blob/trunk/NEWS.txt[NEWS.txt].
* For using cqlsh, the latest version of
Python 3.6+ or Python 2.7 (support deprecated). To verify
* For using cqlsh, the latest version of Python 3.8+. To verify
that you have the correct version of Python installed, type
`python --version`.

Expand Down
Binary file not shown.
Binary file added lib/cassandra-driver-internal-only-3.29.2.zip
Binary file not shown.
2 changes: 0 additions & 2 deletions pylib/Dockerfile.ubuntu.py2

This file was deleted.

2 changes: 1 addition & 1 deletion pylib/Dockerfile.ubuntu.py3
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM ubuntu:bionic
RUN apt-get update && apt-get install -y python3-minimal && update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1
RUN apt-get update && apt-get install -y python3.8-minimal && update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
2 changes: 2 additions & 0 deletions pylib/Dockerfile.ubuntu.py312
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM ubuntu:bionic
RUN apt-get update && apt-get install -y python3.12-minimal && update-alternatives --install /usr/bin/python python /usr/bin/python3.12 1
2 changes: 0 additions & 2 deletions pylib/Dockerfile.ubuntu.py37

This file was deleted.

2 changes: 0 additions & 2 deletions pylib/Dockerfile.ubuntu.py38

This file was deleted.

5 changes: 2 additions & 3 deletions pylib/README.asc
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
== Overview

This directory contains code primarily for cqlsh. cqlsh uses cqlshlib in this directory.
Currently, cqlshlib supports Python 2 as well as Python 3. Support for Python 3 is relatively
new.
Currently, cqlshlib supports Python 3.8-3.12.

== Requirements
. Python 3 and 2.7 (for cqlsh)
. Python 3.8-3.12 (for cqlsh)
. virtualenv
. Docker (optional)

Expand Down
Loading