Skip to content

Instantly share code, notes, and snippets.

@ryansechrest
Last active October 14, 2017 15:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryansechrest/5b21f8abf1a2023391b2 to your computer and use it in GitHub Desktop.
Save ryansechrest/5b21f8abf1a2023391b2 to your computer and use it in GitHub Desktop.
Create a Python command-line tool.

Install Python

yum install python

Install pip

Manage packages from Python Package Index.

wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py

Install virtualenv

Build virtual Python environment.

pip install virtualenv

Create project dir

mkdir hello
cd hello

Setup and activate virtual env

virtualenv venv
. venv/bin/activate

Install program

pip install --editable .
import click
@click.command()
def cli():
"""Example script."""
click.echo('Hello World!')
from setuptools import setup
setup(
name='hello',
version='0.1',
py_modules=['hello'],
install_requires=[
'click',
],
entry_points='''
[console_scripts]
hello=hello:cli
''',
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment