Search code examples
pythonmoduledocumentationpep

Python best way to document imported module version in scripts


What is the best way or PEP convention to document the versions of imported modules in single python scripts? Sometimes I have to use older scripts that does not run because of module incompatibility (for example the script was written using pandas 0.15.0 and matplotlib 1.3.0, and now I use pandas 0.18.1 and matplotlib 1.5.1). It would be great for example if the first part of the script would contain pandas (and other imported module's) version in comment, like:

"""my_script_version = '0.0.1'
pandas_version = '0.15.0'
matplotlib_version = '1.3.0'
other_imported_module_version = 'x.y.z'
"""

Or is there any official way to do this? Something like using some metadatas?

__version__ = '0.0.1'
__date__ = '2016-06-06'
__author__ = 'ragesz'

__pandas_version__ = '0.15.0'
__matplotlib_version__ = '1.3.0'
__other_imported_module_version__ = 'x.y.z'

Thank you!


Solution

  • PEP 518 has been accepted recently regarding your question.

    Dependencies has to be stored in a specific file pyproject.toml

    [build-system]
    # Minimum requirements for the build system to execute.
    requires = ["setuptools", "wheel"]  # PEP 508 specifications.
    

    PEP 508 specify syntax for the requirements.