forked from gorakhargosh/watchdog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
169 lines (153 loc) · 5.08 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2011 Yesudeep Mangalapilly <[email protected]>
# Copyright 2012 Google, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
import imp
import os.path
from setuptools import setup, find_packages
from setuptools.extension import Extension
from setuptools.command.build_ext import build_ext
from distutils.util import get_platform
SRC_DIR = 'src'
WATCHDOG_PKG_DIR = os.path.join(SRC_DIR, 'watchdog')
version = imp.load_source('version',
os.path.join(WATCHDOG_PKG_DIR, 'version.py'))
PLATFORM_LINUX = 'linux'
PLATFORM_WINDOWS = 'windows'
PLATFORM_MACOSX = 'macosx'
PLATFORM_BSD = 'bsd'
# Determine platform to pick the implementation.
def determine_platform():
platform = get_platform()
if platform.startswith('macosx'):
platform = PLATFORM_MACOSX
elif platform.startswith('linux'):
platform = PLATFORM_LINUX
elif platform.startswith('win'):
platform = PLATFORM_WINDOWS
else:
platform = None
return platform
platform = determine_platform()
ext_modules = {
PLATFORM_MACOSX: [
Extension(name='_watchdog_fsevents',
sources=[
'src/watchdog_fsevents.c',
],
libraries=['m'],
define_macros=[
('WATCHDOG_VERSION_STRING',
'"' + version.VERSION_STRING + '"'),
('WATCHDOG_VERSION_MAJOR', version.VERSION_MAJOR),
('WATCHDOG_VERSION_MINOR', version.VERSION_MINOR),
('WATCHDOG_VERSION_BUILD', version.VERSION_BUILD),
],
extra_link_args=[
'-framework', 'CoreFoundation',
'-framework', 'CoreServices',
],
extra_compile_args=[
'-std=c99',
'-pedantic',
'-Wall',
'-Wextra',
'-fPIC',
]
),
],
}
extra_args = dict(
cmdclass={
'build_ext': build_ext
},
ext_modules=ext_modules.get(platform, []),
)
install_requires = ['PyYAML >=3.09',
'argh >=0.8.1',
'pathtools']
if sys.version_info < (2, 7, 0):
# argparse is merged into Python 2.7 in the Python 2x series
# and Python 3.2 in the Python 3x series.
install_requires.append('argparse >=1.1')
if any([key in sys.platform for key in ['bsd', 'darwin']]):
# Python 2.6 and below have the broken/non-existent kqueue implementations
# in the select module. This backported patch adds one from Python 2.7,
# which works.
install_requires.append('select_backport >=0.2')
def read_file(filename):
"""
Reads the contents of a given file relative to the directory
containing this file and returns it.
:param filename:
The file to open and read contents from.
"""
return open(os.path.join(os.path.dirname(__file__), filename)).read()
if not sys.version_info < (3,):
extra_args.update(dict(use_2to3=True))
setup(name="watchdog",
version=version.VERSION_STRING,
description="Filesystem events monitoring",
long_description=read_file('README'),
author="Yesudeep Mangalapilly",
author_email="[email protected]",
license="Apache License 2.0",
url="http://github.com/gorakhargosh/watchdog",
keywords=' '.join([
'python',
'filesystem',
'monitoring',
'monitor',
'FSEvents',
'kqueue',
'inotify',
'ReadDirectoryChangesW',
'polling',
'DirectorySnapshot',
]
),
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Console',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Operating System :: MacOS :: MacOS X',
'Operating System :: POSIX :: BSD',
'Operating System :: Microsoft :: Windows :: Windows NT/2000',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: C',
'Topic :: Software Development :: Libraries',
'Topic :: System :: Monitoring',
'Topic :: System :: Filesystems',
'Topic :: Utilities',
],
package_dir={'': SRC_DIR},
packages=find_packages(SRC_DIR),
include_package_data=True,
install_requires=install_requires,
entry_points={
'console_scripts': [
'watchmedo = watchdog.watchmedo:main',
]
},
zip_safe=False,
**extra_args
)