I'm putting together my first package so that I can easily share it with others and I've come across what is a somewhat vague aspect to me - I don't quite know what the best way to deal with package metadata is.
For example, it seems the best way to set a package version number is using a separate file instead of defining it in the __init__.py
of the main package, as described in this answer: https://stackoverflow.com/a/17626524/1506763. This makes some sense as imports you may have in __init__.py
may cause problems if importing in setup.py
.
But this version question triggered another question with regards to the other metadata that I've declared in __init__.py
, namely:
__author__ = ''
__copyright__ = 'Copyright 2021, {project_name}'
__credits__ = ['{credit_list}']
__license__ = '{license}'
__version__ = '{mayor}.{minor}.{rel}' # will move to own file like in the linked answer
__maintainer__ = ''
__email__ = ''
__status__ = '{dev_status}'
Should any of these actually be declared in the __init__.py
file? Should they also be treated like version in the linked answer?
I've seen this post suggest all the various attributes that should be defined per module What is the common header format of Python files?, but that seems to be more related to single file modules rather than a package with several sub-packages and modules.
Or should all this metadata be included in the __init__.py
of the sub-packages as well in case the sub-packages are getting imported on their own.
Is there a well defined example that explains this aspect of how to set-up your package (and it's sub-packages)?