Creating a package for distribution can be a tedious task for unexperienced developers. Most of the metadata that setuptools or distuitls accept in their setup() function call can be provided manually ignoring the fact that this metadata may be also available in other parts of the project. Here is an example:
from setuptools import setup setup( name="myproject", version="0.0.1", description="mypackage project short description", long_description=""" Longer description of mypackage project possibly with some documentation and/or usage examples """, install_requires=[ 'dependency1', 'dependency2', 'etc', ] )
Some of the metadata elements are often found in different places in a typical Python project. For instance, content of long description is commonly included in the project's README file, and it is a good convention to put a version specifier in the __init__
module of the package. Hardcoding such package metadata as setup() function arguments redundancy to the project that allows for easy mistakes and inconsistencies in future. Both setuptools and distutils cannot automatically pick metadata information from the project sources, so you need to provide it yourself. There are some common patterns among the Python community for solving the most popular problems such as dependency management, version/readme inclusion, and so on. It is worth knowing at least a few of them because they are so popular that they could be considered as packaging idioms.