Merge pull request #16 from Infinidat/master
[python-kmod.git] / setup.py
index 2a63b4b19c944a691a58e196f9edf07c76cc3887..f6e25b75e92b4343bb47553813be3fc7d91f92a3 100644 (file)
--- a/setup.py
+++ b/setup.py
 #
 # You should have received a copy of the GNU Lesser General Public License
 # along with python-kmod.  If not, see <http://www.gnu.org/licenses/>.
-
-from distutils.core import setup
+from setuptools import setup
 from distutils.extension import Extension as _Extension
 import os as _os
 import sys as _sys
+import platform
 
-from Cython.Distutils import build_ext as _build_ext
-
+# setuptools DWIM monkey-patch madness
+# http://mail.python.org/pipermail/distutils-sig/2007-September/thread.html#8204
+import sys
+if 'setuptools.extension' in sys.modules:
+    m = sys.modules['setuptools.extension']
+    m.Extension.__dict__ = m._Extension.__dict__
 
 package_name = 'kmod'
 
@@ -34,15 +38,16 @@ from version import __version__
 _this_dir = _os.path.dirname(__file__)
 
 ext_modules = []
-for filename in sorted(_os.listdir(package_name)):
-    basename,extension = _os.path.splitext(filename)
-    if extension == '.pyx':
-        ext_modules.append(
-            _Extension(
-                '{0}.{1}'.format(package_name, basename),
-                [_os.path.join(package_name, filename)],
-                libraries=['kmod'],
-                ))
+if platform.system() == "Linux":
+    for filename in sorted(_os.listdir(package_name)):
+        basename,extension = _os.path.splitext(filename)
+        if extension == '.pyx':
+            ext_modules.append(
+                _Extension(
+                    '{0}.{1}'.format(package_name, basename),
+                    [_os.path.join(package_name, filename)],
+                    libraries=['kmod'],
+                    ))
 
 setup(
     name=package_name,
@@ -52,6 +57,7 @@ setup(
     provides=[package_name],
     maintainer="Andy Grover",
     maintainer_email="agrover@redhat.com",
-    cmdclass = {'build_ext': _build_ext},
     ext_modules=ext_modules,
+    install_requires=["Cython"],
+    setup_requires=["setuptools_cython"],
     )