Make directory path(s) to keep things organized…

mkdir -vp ~/git/hub/development-tutorials

Initialize new Git repository…

git init ~/git/hub/development-tutorials/python-first-library

Note, throughout this tutorial the python-first-library repository directory should be replaced with the directory name for your library.

Change current working directory to your new project repository…

cd ~/git/hub/development-tutorials/python-first-library

… add hub as a remote…

git remote add hub git@github.com:development-tutorials/python-first-library.git

Note, URL syntax is git@github.com:<account>/<repository>.git

… touch files for setuptools into existence…

touch .gitignore
touch MANIFEST.in
touch requirements.txt
touch setup.cfg
touch setup.py

… finally make directory structure for project source code, and touch files for library and Command Line Interface example into existence…

mkdir -vp python_first_library/cli


touch python_first_library/__init__.py
touch python_first_library/cli/__init__.py

# Notes about files

  • .gitignore defines directory and file patterns that Git should ignore from version tracking

  • MANIFEST.in defines files not automatically detected by setuptools that need to be included within package archive

  • requirements.txt should define developer dependencies, note install dependencies will need to be defined within setup.py file

  • setup.cfg defines metadata about this project and may be used by code linters (code style enforcement tools)

  • setup.py is read/executed during installation process when pip install <name> is issued by users of this project

  • python_first_library/__init__.py will contain the main class(s) for this project that other projects should import

  • python_first_library/cli/__init__.py will contain fully functional example usage of project code as a command line application