This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch CASSANDRA-18642-5.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git

commit 2b638f6c156b2b64ad6bb7bc19ffbe43bca8572d
Author: Brandon Williams <[email protected]>
AuthorDate: Sat Aug 22 10:39:58 2026 -0500

    Change RPM pylib location to /usr/share/cassandra
---
 bin/cqlsh.py          | 13 ++++++++++---
 redhat/cassandra.spec | 17 ++++++++++++-----
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/bin/cqlsh.py b/bin/cqlsh.py
index 5131f99062..80b51f0df7 100755
--- a/bin/cqlsh.py
+++ b/bin/cqlsh.py
@@ -75,9 +75,16 @@ except ImportError as e:
 
 # cqlsh should run correctly when run out of a Cassandra source tree,
 # out of an unpacked Cassandra tarball, and after a proper package install.
-cqlshlibdir = os.path.join(CASSANDRA_PATH, 'pylib')
-if os.path.isdir(cqlshlibdir):
-    sys.path.insert(0, cqlshlibdir)
+CQLSHLIB_DIRS = [os.path.join(CASSANDRA_PATH, 'pylib')]
+
+if platform.system() == 'Linux':
+    # the in-tree redhat/cassandra.spec places pylib here
+    CQLSHLIB_DIRS.append('/usr/share/cassandra/pylib')
+
+for cqlshlibdir in CQLSHLIB_DIRS:
+    if os.path.isdir(os.path.join(cqlshlibdir, 'cqlshlib')):
+        sys.path.insert(0, cqlshlibdir)
+        break
 
 from cqlshlib.cqlshmain import main
 
diff --git a/redhat/cassandra.spec b/redhat/cassandra.spec
index 5aba1ba7e1..0aa4aca215 100644
--- a/redhat/cassandra.spec
+++ b/redhat/cassandra.spec
@@ -24,8 +24,6 @@
 # binary executable files in our 'noarch' package
 %define _binaries_in_noarch_packages_terminate_build   0
 
-%define __python /usr/bin/python3
-
 %global username cassandra
 
 # input of ~alphaN, ~betaN, ~rcN package versions need to retain upstream 
'-alphaN, etc' version for sources
@@ -88,7 +86,15 @@ mkdir -p %{buildroot}/usr/bin
 mkdir -p %{buildroot}/var/lib/%{username}
 mkdir -p %{buildroot}/var/run/%{username}
 mkdir -p %{buildroot}/var/log/%{username}
-( cd pylib && %{__python} setup.py install --no-compile --root %{buildroot}; )
+
+# install the cqlsh python library in a Python-version independent location;
+# cqlsh.py adds it to sys.path at runtime. Installing via 'setup.py install'
+# would bake the build machine's Python site-packages path (and any compiled
+# extension module) into this noarch package, breaking cqlsh on systems with
+# a different Python version
+mkdir -p %{buildroot}/usr/share/%{username}/pylib
+cp -pr pylib/cqlshlib %{buildroot}/usr/share/%{username}/pylib/
+find %{buildroot}/usr/share/%{username}/pylib -name __pycache__ -type d -exec 
rm -rf {} +
 
 # patches for data and log paths
 patch -p1 < debian/patches/cassandra_yaml_dirs.diff
@@ -164,8 +170,6 @@ exit 0
 %attr(755,%{username},%{username}) %config(noreplace) /var/lib/%{username}
 %attr(755,%{username},%{username}) /var/log/%{username}*
 %attr(755,%{username},%{username}) /var/run/%{username}*
-%{python_sitelib}/cqlshlib/
-%{python_sitelib}/cassandra_pylib*.egg-info
 
 %post
 alternatives --install /%{_sysconfdir}/%{username}/conf %{username} 
/%{_sysconfdir}/%{username}/default.conf/ 0
@@ -208,6 +212,9 @@ This package contains extra tools for working with 
Cassandra clusters.
 
 %changelog
 # packaging changes, not software changes
+* Sat Aug 22 2026 Brandon Williams <[email protected]>
+- Install pylib/cqlshlib under /usr/share/cassandra/pylib instead of
+  'setup.py install' into the build machine's Python site-packages;
 * Thu May 04 2023 Mick Semb Wever <[email protected]>
 - 5.0
 - RPM packaging brought in-tree. CASSANDRA-18133


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to