PBR

How do I specify a __version__ of a Python package?

Bug #1820042 reported by Peter Bittner
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PBR
New
Undecided
Unassigned

Bug Description

It's not clear from the documentation how a package maintainer should specify the version string, so that PBR automatically detects it for setuptools.

My habit is to put a code like this into the `<package_name>/__init__.py` file:

    """
    Package description (i.e. __doc__ is parsed in setup.py)
    """
    __author__ = 'Author Name'
    __email__ = '<email address hidden>'
    __license__ = 'GPLv3'
    __url__ = 'https://github.com/example/repository'
    __version__ = '0.1.2.dev1'

While it may be debatable whether to include author, email, url and license information I guess it's widespread to include `__version__` in <package>/__init__.py (when you do it the right way, i.e. have no other code in the file).

Parsing <package_name>.__doc__ for auto-generating a package description, optionally overridden in setup.cfg, may also make sense for package quality and help to reduce clutter in Python package projects.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.