Menu

#14 Support for __version__

closed
None
5
2015-01-22
2013-01-28
No

I suggest that something gets added so that python code using PyWBEM can easily find out the package version.
Relying on modules that determine this from site package installation information are not always reliable (e.g. because PyWBEM may not necessarily be installed as a site package).

I have seen the use of a global variable {package-name}.__version__ as a convention on how to do that, and suggest that PyWBEM also follows that convention.

This could for example be done by adding __version__ = "0.7.1" to __init__.py.

Instead of defining the version a second time in setup.py, setup.py could then pick up the version defined in __init__.py, by using execfile() on the __init__.py module, as outlined here:
http://stackoverflow.com/questions/2058802/how-can-i-get-the-version-defined-in-setup-py-setuptools-in-my-package/2073599#2073599
Note that the alternative approach of importing __init__.py that is also mentioned somewhere in that thread does not work for customers that never had PyWBEM installed before.

Discussion

  • Andreas Maier

    Andreas Maier - 2014-09-05

    In addition, I found that the use of {package-name}.version causes the help() function to produce a VERSION section.

    I think that documentation of {package-name}.version by means of listing it in the DATA ATTRIBUTES section of help() is sufficient.

    Using Python 2.6.6:

    >>> help(pywbem)
    Help on package pywbem:
    
    NAME
        pywbem - pywbem - WBEM client bindings for Python.
    
    FILE
        c:\python26\lib\site-packages\pywbem\__init__.py
    
    DESCRIPTION
        PyWBEM is a Python library ...
    
    PACKAGE CONTENTS
        cim_constants
        ...
    
    DATA
        ...
        __version__ = '0.8.0-dev'
        ...
    
    VERSION
        0.8.0-dev
    
     
  • Andreas Maier

    Andreas Maier - 2014-09-05

    Committed the attached version_v1.patch as r635.
    This bug can be closed.

     
  • Andreas Maier

    Andreas Maier - 2014-10-10
    • status: open --> closed
    • assigned_to: Andreas Maier
    • Group: --> v0.8.0