Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds parameter to ignore platform check #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 38 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,51 @@
import sys
import distutils.extension
from distutils.util import get_platform
from setuptools.command.install import install


try:
# First try to load most advanced setuptools setup.
from setuptools import setup
except:
# Fall back if setuptools is not installed.
from distutils.core import setup


platform = get_platform()


class InstallCommand(install):
user_options = install.user_options + [
('no-platform-check', None, 'Default?')
]

def initialize_options(self):
install.initialize_options(self)
self.no_platform_check = None

def run(self):
global platform
if not platform.startswith('linux') and \
not platform.startswith('freebsd'):
if self.no_platform_check is not None:
sys.stdout.write(
"inotify is not available on %s,"
"but check is ignored\n" % platform)
else:
# check linux platform
sys.stderr.write(
"inotify is not available on %s "
"(--no-platform-check forces install)\n" % platform)
sys.exit(1)
install.run(self)


# check Python's version
if sys.version_info < (2, 4):
sys.stderr.write('This module requires at least Python 2.4\n')
sys.exit(1)

# check linux platform
if not platform.startswith('linux') and not platform.startswith('freebsd'):
sys.stderr.write("inotify is not available on %s\n" % platform)
sys.exit(1)


classif = [
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
Expand Down Expand Up @@ -83,25 +108,26 @@ def should_compile_ext_mod():
libc = ctypes.CDLL(libc_name)
# Eventually check that libc has needed inotify bindings.
if (not hasattr(libc, 'inotify_init') or
not hasattr(libc, 'inotify_add_watch') or
not hasattr(libc, 'inotify_rm_watch')):
not hasattr(libc, 'inotify_add_watch') or
not hasattr(libc, 'inotify_rm_watch')):
return True
return False


ext_mod = []
if compile_ext_mod or should_compile_ext_mod():
# add -fpic if x86_64 arch
if platform in ["linux-x86_64"]:
os.environ["CFLAGS"] = "-fpic"
# sources for ext module
ext_mod_src = ['common/inotify_syscalls.c']
# dst for ext module
ext_mod.append(distutils.extension.Extension('inotify_syscalls',
ext_mod_src))
ext_mod_src = ['common/inotify_syscalls.c']

ext_mod = [distutils.extension.Extension('inotify_syscalls', ext_mod_src)]

setup(
cmdclass={
'install': InstallCommand
},
name='pyinotify',
version='0.9.6',
description='Linux filesystem events monitoring',
Expand Down