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