1# coding: utf-8 2# 3# Copyright 2011 Yesudeep Mangalapilly <yesudeep@gmail.com> 4# Copyright 2012 Google, Inc & contributors. 5# 6# Licensed under the Apache License, Version 2.0 (the "License"); 7# you may not use this file except in compliance with the License. 8# You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, software 13# distributed under the License is distributed on an "AS IS" BASIS, 14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15# See the License for the specific language governing permissions and 16# limitations under the License. 17 18import importlib.util 19import sys 20import os 21import os.path 22from platform import machine 23from setuptools import setup, find_packages 24from setuptools.extension import Extension 25from setuptools.command.build_ext import build_ext 26 27SRC_DIR = 'src' 28WATCHDOG_PKG_DIR = os.path.join(SRC_DIR, 'watchdog') 29 30# Load the module version 31spec = importlib.util.spec_from_file_location( 32 'version', os.path.join(WATCHDOG_PKG_DIR, 'version.py')) 33version = importlib.util.module_from_spec(spec) 34spec.loader.exec_module(version) 35 36# Ignored Apple devices on which compiling watchdog_fsevents.c would fail. 37# The FORCE_MACOS_MACHINE envar, when set to 1, will force the compilation. 38_apple_devices = ('appletv', 'iphone', 'ipod', 'ipad', 'watch') 39is_macos = sys.platform == 'darwin' and not machine().lower().startswith(_apple_devices) 40 41ext_modules = [] 42if is_macos or os.getenv('FORCE_MACOS_MACHINE', '0') == '1': 43 ext_modules = [ 44 Extension( 45 name='_watchdog_fsevents', 46 sources=[ 47 'src/watchdog_fsevents.c', 48 ], 49 libraries=['m'], 50 define_macros=[ 51 ('WATCHDOG_VERSION_STRING', 52 '"' + version.VERSION_STRING + '"'), 53 ('WATCHDOG_VERSION_MAJOR', version.VERSION_MAJOR), 54 ('WATCHDOG_VERSION_MINOR', version.VERSION_MINOR), 55 ('WATCHDOG_VERSION_BUILD', version.VERSION_BUILD), 56 ], 57 extra_link_args=[ 58 '-framework', 'CoreFoundation', 59 '-framework', 'CoreServices', 60 ], 61 extra_compile_args=[ 62 '-std=c99', 63 '-pedantic', 64 '-Wall', 65 '-Wextra', 66 '-fPIC', 67 68 # Issue #620 69 '-Wno-nullability-completeness', 70 # Issue #628 71 '-Wno-nullability-extension', 72 '-Wno-newline-eof', 73 74 # required w/Xcode 5.1+ and above because of '-mno-fused-madd' 75 '-Wno-error=unused-command-line-argument' 76 ] 77 ), 78 ] 79 80extras_require = { 81 'watchmedo': ['PyYAML>=3.10'], 82} 83 84with open('README.rst', encoding='utf-8') as f: 85 readme = f.read() 86 87with open('changelog.rst', encoding='utf-8') as f: 88 changelog = f.read() 89 90setup(name="watchdog", 91 version=version.VERSION_STRING, 92 description="Filesystem events monitoring", 93 long_description=readme + '\n\n' + changelog, 94 long_description_content_type="text/x-rst", 95 author="Yesudeep Mangalapilly", 96 author_email="yesudeep@gmail.com", 97 license="Apache License 2.0", 98 url="https://github.com/gorakhargosh/watchdog", 99 keywords=' '.join([ 100 'python', 101 'filesystem', 102 'monitoring', 103 'monitor', 104 'FSEvents', 105 'kqueue', 106 'inotify', 107 'ReadDirectoryChangesW', 108 'polling', 109 'DirectorySnapshot', 110 ]), 111 classifiers=[ 112 'Development Status :: 3 - Alpha', 113 'Environment :: Console', 114 'Intended Audience :: Developers', 115 'Intended Audience :: System Administrators', 116 'License :: OSI Approved :: Apache Software License', 117 'Natural Language :: English', 118 'Operating System :: POSIX :: Linux', 119 'Operating System :: MacOS :: MacOS X', 120 'Operating System :: POSIX :: BSD', 121 'Operating System :: Microsoft :: Windows :: Windows Vista', 122 'Operating System :: Microsoft :: Windows :: Windows 7', 123 'Operating System :: Microsoft :: Windows :: Windows 8', 124 'Operating System :: Microsoft :: Windows :: Windows 8.1', 125 'Operating System :: Microsoft :: Windows :: Windows 10', 126 'Operating System :: OS Independent', 127 'Programming Language :: Python', 128 'Programming Language :: Python :: 3', 129 'Programming Language :: Python :: 3 :: Only', 130 'Programming Language :: Python :: 3.6', 131 'Programming Language :: Python :: 3.7', 132 'Programming Language :: Python :: 3.8', 133 'Programming Language :: Python :: 3.9', 134 'Programming Language :: Python :: 3.10', 135 'Programming Language :: Python :: Implementation :: PyPy', 136 'Programming Language :: C', 137 'Topic :: Software Development :: Libraries', 138 'Topic :: System :: Monitoring', 139 'Topic :: System :: Filesystems', 140 'Topic :: Utilities', 141 ], 142 package_dir={'': SRC_DIR}, 143 packages=find_packages(SRC_DIR), 144 include_package_data=True, 145 extras_require=extras_require, 146 cmdclass={ 147 'build_ext': build_ext, 148 }, 149 ext_modules=ext_modules, 150 entry_points={'console_scripts': [ 151 'watchmedo = watchdog.watchmedo:main [watchmedo]', 152 ]}, 153 python_requires='>=3.6', 154 zip_safe=False 155) 156