Initialize Project
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-libraryrepository 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
-
.gitignoredefines directory and file patterns that Git should ignore from version tracking -
MANIFEST.indefines files not automatically detected bysetuptoolsthat need to be included within package archive -
requirements.txtshould define developer dependencies, note install dependencies will need to be defined withinsetup.pyfile -
setup.cfgdefines metadata about this project and may be used by code linters (code style enforcement tools) -
setup.pyis read/executed during installation process whenpip install <name>is issued by users of this project -
python_first_library/__init__.pywill contain the main class(s) for this project that other projects shouldimport -
python_first_library/cli/__init__.pywill contain fully functional example usage of project code as a command line application