From 017ed4ada283e61179c3466341cb2568337f291f Mon Sep 17 00:00:00 2001 From: Guy Rozendorn Date: Sun, 31 Mar 2013 13:25:30 +0300 Subject: [PATCH] Issue #13 skipping building extensions on non-Linux platforms --- kmod/__init__.py | 6 +++++- setup.py | 20 +++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) 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, -- 2.26.2