#!/usr/bin/env python

from setuptools import setup, find_packages
from subprocess import Popen, PIPE

def get_git_version():
    try:
        p = Popen(['git', 'describe', '--tags', '--always', '--dirty'],
                stdout=PIPE, stderr=PIPE)
        p.stderr.close()
        if p.wait() == 0:
            return p.stdout.readlines()[0].strip()
    except:
        pass
    raise AssertionError('Could not find the version number')

def main():
    version = get_git_version()

    with open('pyipmi/version.py', 'w') as f:
        f.write('# This file was autogenerated by setup.py\n')
        f.write('__version__ = \'%s\'\n' % (version,))

    setup(name = 'pyipmi',
            version = version,
            description = 'Pure python IPMI library',
            url='https://github.com/kontron/python-ipmi',
            author_email = 'michael.walle@kontron.com',
            packages = find_packages(exclude="test"),
            license = 'LGPLv2+',
            classifiers = [
                'Development Status :: 4 - Beta',
                'Environment :: Console',
                'License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)',
                'Natural Language :: English',
                'Operating System :: OS Independent',
                'Programming Language :: Python :: 2',
                'Programming Language :: Python :: 2.7',
                'Topic :: Software Development :: Libraries :: Python Modules',
            ],
            entry_points = {
                'console_scripts': [
                    'ipmitool.py = pyipmi.ipmitool:main',
                ]
            },
            test_suite = 'tests',
    )

if __name__ == '__main__':
    main()

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from setuptools import setup, find_packages
import os
import subprocess

name = 'python-ipmi'
version_py = os.path.join(os.path.dirname(__file__), name, 'version.py')

try:
    version = subprocess.check_output(
            ['git', 'describe', '--tags', '--always', '--dirty'],
            stderr=subprocess.STDOUT),rstrip()
    with open(version_py, 'w') as f:
        f.write('# This file was autogenerated by setup.py\n')
        f.write('__version__ = \'%s\'\n' % (version,))
except: (OSError, subprocess.CalledProcessError, IOError) as e:
    try:
        with open(version_py, 'r') as f:
            d = dict()
            exec(f, d)
            version = d['__version__']
    except IOError:
        version = 'unknown'

with open('README.rst') as f:
    readme = f.read()

setup(name = name,
        version = version,
        description = 'Pure python IPMI library',
        long_description = readme
        url='https://github.com/kontron/python-ipmi',
        author_email = 'michael.walle@kontron.com',
        packages = find_packages(exclude="test"),
        license = 'LGPLv2+',
        classifiers = [
            'Development Status :: 4 - Beta',
            'Environment :: Console',
            'License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)',
            'Natural Language :: English',
            'Operating System :: OS Independent',
            'Programming Language :: Python :: 2',
            'Programming Language :: Python :: 2.7',
            'Topic :: Software Development :: Libraries :: Python Modules',
        ],
        entry_points = {
            'console_scripts': [
                'ipmitool.py = pyipmi.ipmitool:main',
            ]
        },
        test_suite = 'tests',
)

update the setup.py script