jeffwidman / cqlsh

Home of the cqlsh package on PyPI. Repackages the official Cassandra cqlsh for lighter-weight installs.
Apache License 2.0
19 stars 7 forks source link

Uses cassandra-driver from /usr/share/cassandra/lib on systems with Cassandra installed #39

Open mgmartian opened 1 month ago

mgmartian commented 1 month ago

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.

mgmartian commented 1 month ago

BTW: Thanks for repackaging cqlsh - we really appreciate this project!

bschoening commented 4 days ago

@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.