Merge pull request #16 from Infinidat/master
[python-kmod.git] / setup.py
1 # Copyright (C) 2012 Red Hat, Inc.
2 #                    W. Trevor King <wking@tremily.us>
3 #
4 # This file is part of python-kmod.
5 #
6 # python-kmod is free software: you can redistribute it and/or modify it under
7 # the terms of the GNU Lesser General Public License version 2.1 as published
8 # by the Free Software Foundation.
9 #
10 # python-kmod is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
13 # details.
14 #
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with python-kmod.  If not, see <http://www.gnu.org/licenses/>.
17 from setuptools import setup
18 from distutils.extension import Extension as _Extension
19 import os as _os
20 import sys as _sys
21 import platform
22
23 # setuptools DWIM monkey-patch madness
24 # http://mail.python.org/pipermail/distutils-sig/2007-September/thread.html#8204
25 import sys
26 if 'setuptools.extension' in sys.modules:
27     m = sys.modules['setuptools.extension']
28     m.Extension.__dict__ = m._Extension.__dict__
29
30 package_name = 'kmod'
31
32 # read version from local kmod/version.py without pulling in
33 # kmod/__init__.py
34 _sys.path.insert(0, package_name)
35 from version import __version__
36
37
38 _this_dir = _os.path.dirname(__file__)
39
40 ext_modules = []
41 if platform.system() == "Linux":
42     for filename in sorted(_os.listdir(package_name)):
43         basename,extension = _os.path.splitext(filename)
44         if extension == '.pyx':
45             ext_modules.append(
46                 _Extension(
47                     '{0}.{1}'.format(package_name, basename),
48                     [_os.path.join(package_name, filename)],
49                     libraries=['kmod'],
50                     ))
51
52 setup(
53     name=package_name,
54     version=__version__,
55     description='Python binding for kmod',
56     packages=[package_name],
57     provides=[package_name],
58     maintainer="Andy Grover",
59     maintainer_email="agrover@redhat.com",
60     ext_modules=ext_modules,
61     install_requires=["Cython"],
62     setup_requires=["setuptools_cython"],
63     )