cqlsh
cqlsh copied to clipboard
Uses cassandra-driver from /usr/share/cassandra/lib on systems with Cassandra installed
In cqlsh/cqlsh.py, there's this bit:
if platform.system() == 'Linux':
ZIPLIB_DIRS.append('/usr/share/cassandra/lib')
On systems that have Cassandra installed, this causes cqlsh to use the cassandra-driver that was installed with the cassandra RPM in preference to the one included in the venv.
In our case, this causes a failure because the cassandra-driver included with Cassandra 3.11.15 in /usr/share/cassandra/lib is not compatible with Python 3.10.
$ cqlsh
Traceback (most recent call last):
File "/some/venv/bin/cqlsh", line 5, in <module>
from cqlsh.__main__ import main
File "/some/venv/lib/python3.10/site-packages/cqlsh/__main__.py", line 3, in <module>
from cqlsh.cqlsh import main as cqlsh_main
File "/some/venv/lib/python3.10/site-packages/cqlsh/cqlsh.py", line 134, in <module>
from cassandra.cluster import Cluster
File "/usr/share/cassandra/lib/cassandra-driver-internal-only-3.11.0-bb96859b.zip/cassandra-driver-3.11.0-bb96859b/cassandra/cluster.py", line 22, in <module>
ImportError: cannot import name 'Mapping' from 'collections' (python3.10.13-cp310-cp310-manylinux2014_x86_64/squashfs-root/opt/python3.10/lib/python3.10/collections/__init__.py)
$
To get around this, we set CQLSH_NO_BUNDLED=1
which disables this behavior... but it seems like when repackaging cqlsh, you should comment out these two lines instead.
BTW: Thanks for repackaging cqlsh - we really appreciate this project!
@mgmartian In Cassandra 5.0 (which is in late Beta), I have refactored the majority of cqlsh.py code into cqlshlib in the Apache Cassandra code base. That change should allow this package to bypass the ziplib oddities and other code specific to running CQLSH from /bin when tarball installed. You can expect an update here once 5.0 drops.
@mgmartian would you be able to try the new build? It's available as a RC with:
pip install --index-url https://test.pypi.org/simple/ cqlsh~=6.2.0rc1
I built a venv with cqlsh 6.2.0rc1 and confirmed that it does not have this issue.
I look forward to picking it up when it's officially released. Thanks!
@mgmartian Cassandra CQLSH 6.2.0 (Apache Cassandra version 5.0) has been released now.