Uploaded image for project: 'Apache Cassandra'
  1. Apache Cassandra
  2. CASSANDRA-17832

Change bin/cqlsh.py shebang to use PATH with env prefix

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • 5.0-alpha1, 5.0
    • CQL/Interpreter
    • None

    Description

      For cqlsh.py this:

      #!/usr/bin/env python

      is preferable to the current hard coded /usr/bin/python3 which doesn't take into account the python interpreter preferences in the users PATH.  'env' is a system binary in /usr/bin that searches $PATH for strings containing the provided argument and returns the first instance it finds. In the above syntax, env will search for the first instance of python in $PATH and return it.

      This is aligned with the recommendations in https://peps.python.org/pep-0394/

      For example, on a MacOS Monterey 12.5.1 with both xcode python and brew installed python:

       

      % /usr/bin/python3 --version
      Python 3.8.9.   (xcode python version)
      % /usr/bin/env python --version
      Python 3.10.6.  (brew python version)
      % python --version
      Python 3.10.6.   (default)
      

      Thus, /usr/bin/python3 doesn't run the expected default python version

      Even the official Python tutorial uses the /usr/bin/env form of shebang: https://docs.python.org/3/tutorial/interpreter.html

       

       

      Attachments

        Activity

          People

            bschoeni Brad Schoening
            bschoeni Brad Schoening
            Brad Schoening
            Brandon Williams, Stefan Miklosovic
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m