From: Guy Rozendorn Date: Sun, 31 Mar 2013 10:25:30 +0000 (+0300) Subject: Issue #13 skipping building extensions on non-Linux platforms X-Git-Tag: v0.9.1~1^2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=017ed4ada283e61179c3466341cb2568337f291f;p=python-kmod.git Issue #13 skipping building extensions on non-Linux platforms --- diff --git a/kmod/__init__.py b/kmod/__init__.py index 20a73ef..0d79787 100644 --- a/kmod/__init__.py +++ b/kmod/__init__.py @@ -17,4 +17,8 @@ "Libkmod -- Python interface to kmod API." from .version import __version__ -from .kmod import Kmod +try: + from .kmod import Kmod +except ImportError: + # this is a non-Linux platform + pass diff --git a/setup.py b/setup.py index 2a63b4b..090e5d5 100644 --- a/setup.py +++ b/setup.py @@ -19,6 +19,7 @@ from distutils.core 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 @@ -34,15 +35,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,