Starter project for Python CLI application. This defaults to using Click, but feel free to substitute with your library of preference. For more information on using Click to build CLI applications in Python, see the documentation.
Make sure you have Python 3.6 or greater (tested with 3.7) installed. The install script uses the built in venv and pip modules for the install, so you shouldn't need to install anything else explicitly.
-
Clone the repo.
-
In the config.ini file, set the name of the main console command you would like to use and where to symlink this script in your PATH (
$HOME/binis the default):[installation] command = <your-preferred-command-name> command_path = %(HOME)s/bin -
Change to the project root directory and run
./install.pyto create the virtual environment, install the app, and link the executable script tocommand_path -
Make sure the
command_pathyou set above is in yourPATHand try running the command name you set forcommand. For example, if you set command tocmd, try:cmd --help -
If successful, you should see the base help output of your application.
Essentially this automates creation of your virtual environment and provides you with an entry point in your path to run your app without having to activate/deactivate the virtual environment.
Basic Dockerfile included to build an image of your app. To use, run:
docker build -t mycli:latest .
You can then run the app with:
docker run mycli:latest cmd --help
-
Clone the repo.
-
Modify the command name in config.ini same as you did above.
-
Modify setup.py as needed to add or remove libraries to install.
-
Create virtual environment:
python3 -m venv .venv -
Activate the virtual environment.
. .venv/bin/activate -
Pip install wheel, followed by your package as editable.
pip install wheel pip install . --editable -
Install any other tools required for your development environment, such as linters like
pylint. -
To exit development environment, run
deactivateor just exit your shell.