示例#1
0
文件: setup.py 项目: pywbem/pywbem
def main():
    """Main function of this script."""

    import_setuptools()
    from setuptools import setup
    from setuptools.command.build_py import build_py as _build_py

    class build_py(_build_py):
        # pylint: disable=invalid-name,too-few-public-methods
        """Custom command that extends the setuptools `build_py` command,
        which prepares the Python files before they are being installed.
        This command is used by `setup.py install` and `pip install`.

        We use this only to pick up the verbosity level.
        """
        def run(self):
            global _VERBOSE  # pylint: disable=global-statement
            _VERBOSE = self.verbose
            _build_py.run(self)

    py_version_m_n = "%s.%s" % (sys.version_info[0], sys.version_info[1])
    py_version_m = "%s" % sys.version_info[0]

    pkg_version = package_version("pywbem/_version.py", "__version__")

    args = {
        'name': 'pywbem',
        'author': 'Tim Potter',
        'author_email': '*****@*****.**',
        'maintainer': 'Andreas Maier',
        'maintainer_email': '*****@*****.**',
        'description': 'pywbem - A WBEM client',
        'long_description': __doc__,
        'platforms': ['any'],
        'url': 'http://pywbem.github.io/pywbem/',
        'version': pkg_version,
        'license': 'LGPL version 2.1, or (at your option) any later version',
        'distclass': os_setup.OsDistribution,
        'cmdclass': {
            'build_py': build_py,
            'install_os': os_setup.install_os,
            'develop_os': os_setup.develop_os,
            'develop': os_setup.develop,
        },
        'packages': ['pywbem'],
        'package_data': {
            'pywbem': [
                'NEWS.md',
                'LICENSE.txt',
            ]
        },
        'scripts': [
            'wbemcli',
            'wbemcli.py',
            'mof_compiler',
            'wbemcli.bat',
            'mof_compiler.bat',
        ],
        'install_requires': [
            # These dependencies will be installed as a site package.
            # They are not useable by this setup script, if they are eggs
            # (because their path is added to a .pth file which is parsed only
            # at Python startup time).
            'six',
            'ply',
            # The PyYAML package contains the "yaml" Python package. yaml is
            # needed by the pywbem._recorder module.
            'PyYAML',
        ],
        'develop_requires': [
            # Wheel may not be installed in every system Python.
            'wheel',
            # Python prereqs for 'develop' command. Handled by os_setup module.
            "pytest>=2.4",
            "pytest-cov",
            "Sphinx>=1.3",
            # Pinning GitPython to 2.0.8 max, due to its use of unittest.case
            # which is not available on Python 2.6.
            # TODO: Track resolution of GitPython issue #540:
            #       https://github.com/gitpython-developers/GitPython/issues/540
            "GitPython==2.0.8",
            "sphinx-git",
            "httpretty",
            "lxml",
            # Astroid is used by Pylint. Astroid 1.3 and above, and Pylint 1.4
            # and above no longer work with Python 2.6, and have been removed
            # from Pypi in 2/2016 after being available for some time.
            # Therefore, we cannot use Pylint under Python 2.6.
            # Also, Pylint does not support Python 3.
            "astroid" if sys.version_info[0:2] == (2, 7) else None,
            "pylint" if sys.version_info[0:2] == (2, 7) else None,
            "mock",
            'flake8',
            "pbr",  # needed by mock
            "twine",  # needed for upload to Pypi
        ],
        'install_os_requires': {
            # OS-level prereqs for 'install_os' command. Handled by os_setup
            # module.
            'Linux': {
                'redhat': [
                    "openssl-devel>=1.0.1",  # for M2Crypto installation
                    "gcc-c++>=4.4",         # for building Swig and for running
                                            #   Swig in M2Crypto install
                    install_swig,           # for running Swig in M2Crypto inst.
                    # Python-devel provides Python.h for Swig run.
                    # The following assumes we have python34, not python34u
                    "python34-devel" if py_version_m_n == "3.4" else \
                    "python35-devel" if py_version_m_n == "3.5" else \
                    "python-devel",
                ],
                'centos': 'redhat',
                'fedora': 'redhat',
                'ubuntu': [
                    "libssl-dev>=1.0.1",
                    "g++>=4.4",
                    install_swig,
                    "python-dev" if py_version_m == "2"
                    else "python%s-dev" % py_version_m,
                ],
                'debian': 'ubuntu',
                'linuxmint': 'ubuntu',
                'suse': [
                    "openssl-devel>=1.0.1",
                    "gcc-c++>=4.4",
                    install_swig,
                    "libpython%s-devel" % py_version_m_n,
                ],
            },
            # TODO: Add support for Windows.
        },
        'develop_os_requires': {
            # OS-level prereqs for 'develop_os' command, in addition to those
            # defined in 'install_os_requires'. Handled by os_setup module.
            'Linux': {
                'redhat': [
                    "libxml2-devel",        # for installing Python lxml pkg
                    "libxml2",              # for installing xmllint command
                    "libxslt-devel",        # for installing Python lxml pkg
                    "libyaml-devel",        # for installing Python pyyaml pkg
                    "make",                 # PyWBEM has a makefile
                    "tar",                  # for distribution archive
                    "git",                  # used by GitPython
                ],
                'centos': 'redhat',
                'fedora': 'redhat',
                'debian': [
                    "libxml2-dev",
                    "libxml2-utils",
                    "libxslt1-dev",
                    "libyaml-dev",
                    "make",
                    "tar",
                    "git",
                ],
                'ubuntu': [
                    "libxml2-dev",
                    "libxml2-utils",
                    "libxslt1-dev",
                    "libyaml-dev",
                    "make",
                    "tar",
                    "git",
                ],
                'linuxmint': [
                    "libxml2-dev",
                    "libxml2-utils",
                    "libxslt1-dev",
                    "libyaml-dev",
                    "make",
                    "tar",
                    "git",
                ],
                'suse': [
                    "libxml2-devel",
                    "libxml2",
                    "libxslt-devel",
                    "libyaml-devel",
                    "make",
                    "tar",
                    "git",
                ],
            },
            # TODO: Add support for Windows. Some notes:
            # - install lxml from its binaries at:
            #   http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml
        },
        'classifiers': [
            'Development Status :: 5 - Production/Stable',
            'Intended Audience :: Developers',
            'Intended Audience :: System Administrators',
            'License :: OSI Approved :: '\
            'GNU Lesser General Public License v2 or later (LGPLv2+)',
            'Operating System :: OS Independent',
            'Programming Language :: Python :: 2',
            'Programming Language :: Python :: 2.6',
            'Programming Language :: Python :: 2.7',
            'Programming Language :: Python :: 3',
            'Programming Language :: Python :: 3.4',
            'Programming Language :: Python :: 3.5',
            'Topic :: Software Development :: Libraries :: Python Modules',
            'Topic :: System :: Systems Administration',
        ],
    }

    _ON_RTD = os.environ.get('READTHEDOCS', None) == 'True'

    if sys.version_info[0] == 2 and not _ON_RTD:
        # RTD does not have Swig so we cannot install M2Crypto.

        # The 'install_requires' processing in distutils does not tolerate
        # a None value in the list, so we need be truly conditional (instead
        # of adding an entry with None).
        if platform.system() == 'Windows':
            if platform.architecture()[0] == '64bit':
                m2crypto_req = 'M2CryptoWin64>=0.21'
            else:
                m2crypto_req = 'M2CryptoWin32>=0.21'
        else:
            m2crypto_req = 'M2Crypto>=0.24'
        args['install_requires'].append(m2crypto_req)

    # The ordereddict package is a backport of collections.OrderedDict
    # to Python 2.6. OrderedDict is needed by the GitPython package
    # since its 2.0.3 version (but only from 2.0.5 on it is used
    # correctly, and only from 2.0.6 on does it work on Python 2.6).
    # GitPython is needed by sphinx-git. OrderedDict is also needed
    # by the pywbem._recorder module.
    if sys.version_info[0:2] == (2, 6):
        args['install_requires'].append('ordereddict')

    # The following retry logic attempts to handle the frequent xmlrpc
    # errors that recently (9/2016) have shown up with Pypi.
    tries = 2
    while True:
        tries -= 1
        try:
            setup(**args)
        except Fault as exc:
            if tries > 0:
                print("Warning: Retrying setup() because %s was raised: %s" %
                      (exc.__class__.__name__, exc))
                continue
            else:
                raise
        else:
            break

    if 'install' in sys.argv or 'develop' in sys.argv:
        build_moftab(_VERBOSE)

    return 0
示例#2
0
文件: setup.py 项目: j053ph4/pywbem
def main():
    """Main function of this script."""

    import_setuptools()
    from setuptools import setup
    from setuptools.command.build_py import build_py as _build_py

    class build_py(_build_py):
        # pylint: disable=invalid-name,too-few-public-methods
        """Custom command that extends the setuptools `build_py` command,
        which prepares the Python files before they are being installed.
        This command is used by `setup.py install` and `pip install`.

        We use this only to pick up the verbosity level.
        """
        def run(self):
            global _VERBOSE  # pylint: disable=global-statement
            _VERBOSE = self.verbose
            _build_py.run(self)

    py_version_mn = "%s%s" % (sys.version_info[0], sys.version_info[1])
    py_version_m = "%s" % sys.version_info[0]
    yuminst = YumInstaller()

    pkg_version = package_version("pywbem/_version.py", "__version__")

    args = {
        'name': 'pywbem',
        'author': 'Tim Potter',
        'author_email': '*****@*****.**',
        'maintainer': 'Andreas Maier',
        'maintainer_email': '*****@*****.**',
        'description': 'pywbem - A WBEM client',
        'long_description': __doc__,
        'platforms': ['any'],
        'url': 'http://pywbem.github.io/pywbem/',
        'version': pkg_version,
        'license': 'LGPL version 2.1, or (at your option) any later version',
        'distclass': os_setup.OsDistribution,
        'cmdclass': {
            'build_py': build_py,
            'install_os': os_setup.install_os,
            'develop_os': os_setup.develop_os,
            'develop': os_setup.develop,
        },
        'packages': ['pywbem'],
        'package_data': {
            'pywbem': [
                'NEWS.md',
                'LICENSE.txt',
            ]
        },
        'scripts': [
            'wbemcli',
            'wbemcli.py',
            'mof_compiler',
            'wbemcli.bat',
            'mof_compiler.bat',
        ],
        'install_requires': [
            # These dependencies will be installed as a site package.
            # They are not useable by this setup script, if they are eggs
            # (because their path is added to a .pth file which is parsed only
            # at Python startup time).
            'six',
            'ply',
            # The PyYAML package contains the "yaml" Python package. yaml is
            # needed by the pywbem._recorder module.
            'PyYAML',
        ],
        'develop_requires': [
            # Wheel may not be installed in every system Python.
            'wheel',
            # Python prereqs for 'develop' command. Handled by os_setup module.
            "coverage>=4.3",
            "pytest>=2.4",
            "pytest-cov",
            "Sphinx>=1.3" if sys.version_info[0:2] != (2, 6) else None,
            # Pinning GitPython to 2.0.8 max, due to its use of unittest.case
            # which is not available on Python 2.6.
            # TODO: Track resolution of GitPython issue #540:
            #       https://github.com/gitpython-developers/GitPython/issues/540
            "GitPython==2.0.8" if sys.version_info[0:2] != (2, 6) else None,
            "sphinx-git" if sys.version_info[0:2] != (2, 6) else None,
            "httpretty",
            "lxml",
            # Astroid is used by Pylint. Astroid 1.3 and above, and Pylint 1.4
            # and above no longer work with Python 2.6, and have been removed
            # from Pypi in 2/2016 after being available for some time.
            # Therefore, we cannot use Pylint under Python 2.6.
            # Also, Pylint does not support Python 3.
            "astroid" if sys.version_info[0:2] == (2, 7) else None,
            "pylint" if sys.version_info[0:2] == (2, 7) else None,
            "mock",
            'flake8',
            "pbr",  # needed by mock
            "twine",  # needed for upload to Pypi
        ],
        'install_os_requires': {
            # OS-level prereqs for 'install_os' command. Handled by os_setup
            # module.
            'Linux': {
                'redhat': [
                    "openssl-devel>=1.0.1",  # for M2Crypto installation
                    "gcc-c++>=4.4",         # for building Swig and for running
                                            #   Swig in M2Crypto install
                    install_swig,           # for running Swig in M2Crypto inst.
                    # Python*-devel provides Python.h for Swig run.
                    "python-devel" if py_version_m == "2" else \
                    "python%su-devel" % py_version_mn if \
                    yuminst.is_installed('python%su' % py_version_mn)[0] else \
                    "python%s-devel" % py_version_mn
                ],
                'centos': 'redhat',
                'fedora': 'redhat',
                'ubuntu': [
                    "libssl-dev>=1.0.1",
                    "g++>=4.4",
                    install_swig,
                    "python-dev" if py_version_m == "2" else \
                    "python%s-dev" % py_version_m,
                ],
                'debian': 'ubuntu',
                'linuxmint': 'ubuntu',
                'suse': [
                    "openssl-devel>=1.0.1",
                    "gcc-c++>=4.4",
                    install_swig,
                    "python-devel" if py_version_m == "2" else \
                    "python%s-devel" % py_version_m,
                ],
            },
            # TODO: Add support for Windows.
        },
        'develop_os_requires': {
            # OS-level prereqs for 'develop_os' command, in addition to those
            # defined in 'install_os_requires'. Handled by os_setup module.
            'Linux': {
                'redhat': [
                    "libxml2-devel",        # for installing Python lxml pkg
                    "libxml2",              # for installing xmllint command
                    "libxslt-devel",        # for installing Python lxml pkg
                    "libyaml-devel",        # for installing Python pyyaml pkg
                    "make",                 # PyWBEM has a makefile
                    "tar",                  # for distribution archive
                    "git",                  # used by GitPython
                ],
                'centos': 'redhat',
                'fedora': 'redhat',
                'debian': [
                    "libxml2-dev",
                    "libxml2-utils",
                    "libxslt1-dev",
                    "libyaml-dev",
                    "make",
                    "tar",
                    "git",
                ],
                'ubuntu': [
                    "libxml2-dev",
                    "libxml2-utils",
                    "libxslt1-dev",
                    "libyaml-dev",
                    "make",
                    "tar",
                    "git",
                ],
                'linuxmint': [
                    "libxml2-dev",
                    "libxml2-utils",
                    "libxslt1-dev",
                    "libyaml-dev",
                    "make",
                    "tar",
                    "git",
                ],
                'suse': [
                    "libxml2-devel",
                    "libxml2",
                    "libxslt-devel",
                    "libyaml-devel",
                    "make",
                    "tar",
                    "git",
                ],
            },
            # TODO: Add support for Windows. Some notes:
            # - install lxml from its binaries at:
            #   http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml
        },
        'classifiers': [
            'Development Status :: 5 - Production/Stable',
            'Intended Audience :: Developers',
            'Intended Audience :: System Administrators',
            'License :: OSI Approved :: '\
            'GNU Lesser General Public License v2 or later (LGPLv2+)',
            'Operating System :: OS Independent',
            'Programming Language :: Python :: 2',
            'Programming Language :: Python :: 2.6',
            'Programming Language :: Python :: 2.7',
            'Programming Language :: Python :: 3',
            'Programming Language :: Python :: 3.4',
            'Programming Language :: Python :: 3.5',
            'Programming Language :: Python :: 3.6',
            'Topic :: Software Development :: Libraries :: Python Modules',
            'Topic :: System :: Systems Administration',
        ],
    }

    _ON_RTD = os.environ.get('READTHEDOCS', None) == 'True'

    if sys.version_info[0] == 2 and not _ON_RTD:
        # RTD does not have Swig so we cannot install M2Crypto.

        # The 'install_requires' processing in distutils does not tolerate
        # a None value in the list, so we need be truly conditional (instead
        # of adding an entry with None).
        if platform.system() == 'Windows':
            if platform.architecture()[0] == '64bit':
                m2crypto_req = 'M2CryptoWin64>=0.21'
            else:
                m2crypto_req = 'M2CryptoWin32>=0.21'
        else:
            m2crypto_req = 'M2Crypto>=0.24'
        args['install_requires'].append(m2crypto_req)

    # The ordereddict package is a backport of collections.OrderedDict
    # to Python 2.6. OrderedDict is needed by the GitPython package
    # since its 2.0.3 version (but only from 2.0.5 on it is used
    # correctly, and only from 2.0.6 on does it work on Python 2.6).
    # GitPython is needed by sphinx-git. OrderedDict is also needed
    # by the pywbem._recorder module.
    if sys.version_info[0:2] == (2, 6):
        args['install_requires'].append('ordereddict')

    # The following retry logic attempts to handle the frequent xmlrpc
    # errors that recently (9/2016) have shown up with Pypi.
    tries = 2
    while True:
        tries -= 1
        try:
            setup(**args)
        except Fault as exc:
            if tries > 0:
                print("Warning: Retrying setup() because %s was raised: %s" %
                      (exc.__class__.__name__, exc))
                continue
            else:
                raise
        else:
            break

    if 'install' in sys.argv or 'develop' in sys.argv:
        build_moftab(_VERBOSE)

    return 0
示例#3
0
def main():
    """Main function of this script."""

    import_setuptools()
    from setuptools import setup
    from setuptools.command.build_py import build_py as _build_py

    class build_py(_build_py):
        # pylint: disable=invalid-name,too-few-public-methods
        """Custom command that extends the setuptools `build_py` command,
        which prepares the Python files before they are being installed.
        This command is used by `setup.py install` and `pip install`.

        We use this only to pick up the verbosity level.
        """
        def run(self):
            global _VERBOSE  #pylint: disable=global-statement
            _VERBOSE = self.verbose
            _build_py.run(self)

    py_version_m_n = "%s.%s" % (sys.version_info[0], sys.version_info[1])
    py_version_m = "%s" % sys.version_info[0]

    pkg_version = package_version("pywbem/_version.py", "__version__")

    args = {
        'name': 'pywbem',
        'author': 'Tim Potter',
        'author_email': '*****@*****.**',
        'maintainer': 'Andreas Maier',
        'maintainer_email': '*****@*****.**',
        'description': 'PyWBEM Client - A WBEM client and related utilities',
        'long_description': __doc__,
        'platforms': ['any'],
        'url': 'http://pywbem.github.io/pywbem/',
        'version': pkg_version,
        'license': 'LGPL version 2.1, or (at your option) any later version',
        'distclass': os_setup.OsDistribution,
        'cmdclass': {
            'build_py': build_py,
            'install_os': os_setup.install_os,
            'develop_os': os_setup.develop_os,
            'develop': os_setup.develop,
        },
        'packages': ['pywbem'],
        'package_data': {
            'pywbem': [
                'NEWS.md',
                'LICENSE.txt',
            ]
        },
        'scripts': [
            'wbemcli',
            'mof_compiler',
            'wbemcli.bat',
            'mof_compiler.bat',
        ],
        'install_requires': [
            # These dependencies will be installed as a site package.
            # They are not useable by this setup script, if they are eggs
            # (because their path is added to a .pth file which is parsed only
            # at Python startup time).
            'six',
            'ply',
        ],
        'develop_requires' : [
            # Python prereqs for 'develop' command. Handled by os_setup module.
            "pytest>=2.4",
            "pytest-cov",
            "Sphinx>=1.3",
            # The ordereddict package is a backport of collections.OrderedDict
            # to Python 2.6. OrderedDict is needed by the GitPython package
            # since its 2.0.3 version (but only its 2.0.5 version uses it
            # correctly). GitPython is needed by sphinx-git.
            "ordereddict" if sys.version_info[0:2] == (2, 6) else None,
            "GitPython>=2.0.5",
            "sphinx-git",
            "httpretty",
            "lxml",
            "PyYAML",   # Pypi package name of "yaml" package.
            # Astroid is used by Pylint. Astroid 1.3 and above, and Pylint 1.4
            # and above no longer work with Python 2.6, and have been removed
            # from Pypi in 2/2016 after being available for some time.
            # Therefore, we cannot use Pylint under Python 2.6.
            # Also, Pylint does not support Python 3.
            "astroid" if sys.version_info[0:2] == (2, 7) else None,
            "pylint" if sys.version_info[0:2] == (2, 7) else None,
            "mock",
            "pbr", # needed by mock
            "twine", # needed for upload to Pypi
        ],
        'install_os_requires': {
            # OS-level prereqs for 'install_os' command. Handled by os_setup
            # module.
            'Linux': {
                'redhat': [
                    "openssl-devel>=1.0.1", # for M2Crypto installation
                    "gcc-c++>=4.4",         # for building Swig and for running
                                            #   Swig in M2Crypto install
                    install_swig,           # for running Swig in M2Crypto inst.
                    # Python-devel provides Python.h for Swig run.
                    ["python34-devel", "python34u-devel", "python3-devel"] \
                        if py_version_m_n == "3.4" else \
                    ["python35-devel", "python35u-devel", "python3-devel"] \
                        if py_version_m_n == "3.5" else \
                    "python-devel",
                ],
                'centos': 'redhat',
                'fedora': 'redhat',
                'ubuntu': [
                    "libssl-dev>=1.0.1",
                    "g++>=4.4",
                    install_swig,
                    "python-dev" if py_version_m == "2"
                    else "python%s-dev" % py_version_m,
                ],
                'debian': 'ubuntu',
                'linuxmint': 'ubuntu',
                'suse': [
                    "openssl-devel>=1.0.1",
                    "gcc-c++>=4.4",
                    install_swig,
                    "libpython%s-devel" % py_version_m_n,
                ],
            },
            # TODO: Add support for Windows.
        },
        'develop_os_requires': {
            # OS-level prereqs for 'develop_os' command, in addition to those
            # defined in 'install_os_requires'. Handled by os_setup module.
            'Linux': {
                'redhat': [
                    "libxml2-devel",        # for installing Python lxml pkg
                    "libxml2",              # for installing xmllint command
                    "libxslt-devel",        # for installing Python lxml pkg
                    "libyaml-devel",        # for installing Python pyyaml pkg
                    "make",                 # PyWBEM has a makefile
                    "tar",                  # for distribution archive
                ],
                'centos': 'redhat',
                'fedora': 'redhat',
                'debian': [
                    "libxml2-dev",
                    "libxml2-utils",
                    "libxslt1-dev",
                    "libyaml-dev",
                    "make",
                    "tar",
                ],
                'ubuntu': [
                    "libxml2-dev",
                    "libxml2-utils",
                    "libxslt1-dev",
                    "libyaml-dev",
                    "make",
                    "tar",
                ],
                'linuxmint': [
                    "libxml2-dev",
                    "libxml2-utils",
                    "libxslt1-dev",
                    "libyaml-dev",
                    "make",
                    "tar",
                ],
                'suse': [
                    "libxml2-devel",
                    "libxml2",
                    "libxslt-devel",
                    "libyaml-devel",
                    "make",
                    "tar",
                ],
            },
            # TODO: Add support for Windows. Some notes:
            # - install lxml from its binaries at:
            #   http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml
        },
        'classifiers' : [
            'Development Status :: 5 - Production/Stable',
            'Intended Audience :: Developers',
            'Intended Audience :: System Administrators',
            'License :: OSI Approved :: '\
                'GNU Lesser General Public License v2 or later (LGPLv2+)',
            'Operating System :: OS Independent',
            'Programming Language :: Python :: 2',
            'Programming Language :: Python :: 2.6',
            'Programming Language :: Python :: 2.7',
            'Programming Language :: Python :: 3',
            'Programming Language :: Python :: 3.4',
            'Programming Language :: Python :: 3.5',
            'Topic :: Software Development :: Libraries :: Python Modules',
            'Topic :: System :: Systems Administration',
        ],
    }

    _ON_RTD = os.environ.get('READTHEDOCS', None) == 'True'

    if sys.version_info[0] == 2 and not _ON_RTD:
        # RTD does not have Swig so we cannot install M2Crypto.

        # The 'install_requires' processing in distutils does not tolerate
        # a None value in the list, so we need be truly conditional (instead
        # of adding an entry with None).
        if platform.system() == 'Windows':
            if platform.architecture()[0] == '64bit':
                m2crypto_req = 'M2CryptoWin64>=0.21'
            else:
                m2crypto_req = 'M2CryptoWin32>=0.21'
        else:
            m2crypto_req = 'M2Crypto>=0.24'
        args['install_requires'] += [
            m2crypto_req,
        ]

    setup(**args)

    if 'install' in sys.argv or 'develop' in sys.argv:
        build_moftab(_VERBOSE)

    return 0
示例#4
0
文件: setup.py 项目: jealous/pywbem
def main():
    """Main function of this script."""

    import_setuptools()
    from setuptools import setup
    from setuptools.command.build_py import build_py as _build_py

    class build_py(_build_py):
    # pylint: disable=invalid-name,too-few-public-methods
        """Custom command that extends the setuptools `build_py` command,
        which prepares the Python files before they are being installed.
        This command is used by `setup.py install` and `pip install`.

        We use this only to pick up the verbosity level.
        """
        def run(self):
            global _VERBOSE  #pylint: disable=global-statement
            _VERBOSE = self.verbose
            _build_py.run(self)

    py_version_m_n = "%s.%s" % (sys.version_info[0], sys.version_info[1])
    py_version_m = "%s" % sys.version_info[0]

    pkg_version = package_version("pywbem/_version.py", "__version__")

    args = {
        'name': 'pywbem',
        'author': 'Tim Potter',
        'author_email': '*****@*****.**',
        'maintainer': 'Andreas Maier',
        'maintainer_email': '*****@*****.**',
        'description': 'PyWBEM Client - A WBEM client and related utilities',
        'long_description': __doc__,
        'platforms': ['any'],
        'url': 'http://pywbem.github.io/pywbem/',
        'version': pkg_version,
        'license': 'LGPL version 2.1, or (at your option) any later version',
        'distclass': os_setup.OsDistribution,
        'cmdclass': {
            'build_py': build_py,
            'install_os': os_setup.install_os,
            'develop_os': os_setup.develop_os,
            'develop': os_setup.develop,
        },
        'packages': ['pywbem'],
        'package_data': {
            'pywbem': [
                'NEWS.md',
                'LICENSE.txt',
            ]
        },
        'scripts': [
            'wbemcli',
            'mof_compiler',
            'wbemcli.bat',
            'mof_compiler.bat',
        ],
        'install_requires': [
            # These dependencies will be installed as a site package.
            # They are not useable by this setup script, if they are eggs
            # (because their path is added to a .pth file which is parsed only
            # at Python startup time).
            'six',
            'ply',
        ],
        'develop_requires' : [
            # Python prereqs for 'develop' command. Handled by os_setup module.
            "pytest>=2.4",
            "pytest-cov",
            "Sphinx>=1.3",
            "sphinx-git",
            "httpretty",
            "lxml",
            "PyYAML",   # Pypi package name of "yaml" package.
            # Astroid is used by Pylint. Astroid 1.3 and above, and Pylint 1.4
            # and above no longer work with Python 2.6, and have been removed
            # from Pypi in 2/2016 after being available for some time.
            # Therefore, we cannot use Pylint under Python 2.6.
            # Also, Pylint does not support Python 3.
            "astroid" if sys.version_info[0:2] == (2, 7) else None,
            "pylint" if sys.version_info[0:2] == (2, 7) else None,
        ],
        'install_os_requires': {
            # OS-level prereqs for 'install_os' command. Handled by os_setup
            # module.
            'Linux': {
                'redhat': [
                    "openssl-devel>=1.0.1", # for M2Crypto installation
                    "gcc-c++>=4.4",         # for building Swig and for running
                                            #   Swig in M2Crypto install
                    install_swig,           # for running Swig in M2Crypto inst.
                    # Python-devel provides Python.h for Swig run.
                    ["python34-devel", "python34u-devel", "python3-devel"] \
                        if py_version_m_n == "3.4" else \
                    ["python35-devel", "python35u-devel", "python3-devel"] \
                        if py_version_m_n == "3.5" else \
                    "python-devel",
                    "git>=1.7",             # for retrieving fixed M2Crypto
                ],
                'centos': 'redhat',
                'fedora': 'redhat',
                'ubuntu': [
                    "libssl-dev>=1.0.1",
                    "g++>=4.4",
                    install_swig,
                    "python-dev" if py_version_m == "2"
                    else "python%s-dev" % py_version_m,
                    "git>=1.7",
                ],
                'debian': 'ubuntu',
                'linuxmint': 'ubuntu',
                'suse': [
                    "openssl-devel>=1.0.1",
                    "gcc-c++>=4.4",
                    install_swig,
                    "libpython%s-devel" % py_version_m_n,
                    "git>=1.7",
                ],
            },
            # TODO: Add support for Windows.
        },
        'develop_os_requires': {
            # OS-level prereqs for 'develop_os' command, in addition to those
            # defined in 'install_os_requires'. Handled by os_setup module.
            'Linux': {
                'redhat': [
                    "libxml2-devel",        # for installing Python lxml pkg
                    "libxml2",              # for installing xmllint command
                    "libxslt-devel",        # for installing Python lxml pkg
                    "libyaml-devel",        # for installing Python pyyaml pkg
                    "make",                 # PyWBEM has a makefile
                    "tar",                  # for distribution archive
                ],
                'centos': 'redhat',
                'fedora': 'redhat',
                'debian': [
                    "libxml2-dev",
                    "libxml2-utils",
                    "libxslt1-dev",
                    "libyaml-dev",
                    "make",
                    "tar",
                ],
                'ubuntu': [
                    "libxml2-dev",
                    "libxml2-utils",
                    "libxslt1-dev",
                    "libyaml-dev",
                    "make",
                    "tar",
                ],
                'linuxmint': [
                    "libxml2-dev",
                    "libxml2-utils",
                    "libxslt1-dev",
                    "libyaml-dev",
                    "make",
                    "tar",
                ],
                'suse': [
                    "libxml2-devel",
                    "libxml2",
                    "libxslt-devel",
                    "libyaml-devel",
                    "make",
                    "tar",
                ],
            },
            # TODO: Add support for Windows. Some notes:
            # - install lxml from its binaries at:
            #   http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml
        },
        'classifiers' : [
            'Development Status :: 6 - Mature',
            'Intended Audience :: Developers',
            'Intended Audience :: System Administrators',
            'License :: OSI Approved :: '\
                'GNU Lesser General Public License v2 or later (LGPLv2+)',
            'Operating System :: OS Independent',
            'Programming Language :: Python :: 2.6',
            'Programming Language :: Python :: 2.7',
            'Programming Language :: Python :: 3.4',
            'Programming Language :: Python :: 3.5',
            'Topic :: Software Development :: Libraries :: Python Modules',
            'Topic :: System :: Systems Administration',
        ],
    }

    _ON_RTD = os.environ.get('READTHEDOCS', None) == 'True'

    if sys.version_info[0] == 2 and not _ON_RTD:
        # RTD does not have Swig so we cannot install M2Crypto.

        # The 'install_requires' processing in distutils does not tolerate
        # a None value in the list, so we need be truly conditional (instead
        # of adding an entry with None).
        if platform.system() == 'Windows':
            if platform.architecture()[0] == '64bit':
                m2crypto_req = 'M2CryptoWin64>=0.21'
            else:
                m2crypto_req = 'M2CryptoWin32>=0.21'
        else:
            m2crypto_req = 'M2Crypto>=0.24'
        args['install_requires'] += [
            m2crypto_req,
        ]

    setup(**args)

    if 'install' in sys.argv or 'develop' in sys.argv:
        build_moftab(_VERBOSE)

    return 0