jeffwidman / cqlsh

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

Modularize 'cqlsh' and better support Windows instalation #6

Closed bschoening closed 2 years ago

bschoening commented 2 years ago

This patch is designed to better integrate this PyPI packager with Apache cqlsh. It does not make code changes to cqlsh.py.

The changes here create a new module 'cqlsh', which is required to use setuptools' Entry Point (https://setuptools.pypa.io/en/latest/userguide/entry_point.html). Entry points provide better platform installation; on Linux it will create a shell script for 'cqlsh' which calls the module; on Windows it will create an .exe file.

Note: I've tested these changes on both Linux (MacOS) and Windows 11. The test version of the package can be found at https://test.pypi.org/project/cqlsht/ and installed with:

pip install -i https://test.pypi.org/simple/ cqlsht

On Linux, the executable cqlsh file created by setuptools looks like this:

    $cat /usr/local/bin/cqlsh
    #!/usr/local/opt/python@3.9/bin/python3.9
    # -*- coding: utf-8 -*-
    import re
    import sys
    from cqlsh.__main__ import main
    if __name__ == '__main__':
        sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
        sys.exit(main())
bschoening commented 2 years ago

I realize this needs additional testing.