A simple template for a Python project that can be installed with pip - includes docs and tutorial
Go to source code:
This project is a quick reference, tutorial and demo for making a Python project installable using the pip install PACKAGE
command. For full details, see the linked resources.
From pip docs
pip
can install from either Source Distributions (sdist) or Wheels, but if both are present on PyPI, pip will prefer a compatible wheel.Wheels are a pre-built distribution format that provides faster installation compared to Source Distributions (sdist), especially when a project contains compiled extensions.
If
pip
does not find a wheel to install, it will locally build a wheel and cache it for future installs, instead of rebuilding the source distribution in the future.
pip
or python setup.py
.pip
and a Github URL.Note on publishing:
Here the repo or cloned folder is sample-project
with a hyphen.
Inside the repo is sampleproject
which may not have a hyphen (otherwise you canβt import it as package) and using an underscore is discouraged. See PEP-8.
sample-project
sampleproject/
foo/
__init__.py
__init__.py
sampleproject.py
tests/
setup.py
LICENSE
README.md
Note that a directory and a script are both considered a βmoduleβ in Python, if it can be imported.
See init file tutorial page.
See main file tutorial page.
A main file is a script or an entrypoint to be run directly, but it might be considered a module if you import it from elsewhere. A convention is that this main script matches package name as in the example. You can also make it __main__.py
.
See section of tutorial.
from . import echo
from .. import formats
from ..filters import equalizer
This does not work in the main module.