forked from python-llfuse/python-llfuse
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
Latest commit
executable file
·283 lines (229 loc) · 9.7 KB
/
Copy pathsetup.py
File metadata and controls
executable file
·283 lines (229 loc) · 9.7 KB
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
#!/usr/bin/env python
#-*- coding: us-ascii -*-
'''
setup.py
Installation script for Python-LLFUSE.
Copyright (c) 2010 Nikolaus Rath <Nikolaus.org>
This file is part of Python-LLFUSE. This work may be distributed under
the terms of the GNU LGPL.
'''
from __future__ importdivision, print_function, absolute_import
importsys
importos
importsubprocess
importwarnings
importre
# Disable Cython support in setuptools. It fails under some conditions
# (http://trac.cython.org/ticket/859), and we have our own build_cython command
# anyway.
try:
importCython.Distutils.build_ext
exceptImportError:
pass
else:
# We can't delete Cython.Distutils.build_ext directly,
# because the build_ext class (that is imported from
# the build_ext module in __init__.py) shadows the
# build_ext module.
module=sys.modules['Cython.Distutils.build_ext']
delmodule.build_ext
try:
importsetuptools
exceptImportError:
raiseSystemExit('Setuptools package not found. Please install from '
'https://pypi.python.org/pypi/setuptools')
fromsetuptoolsimportExtension
fromdistutils.versionimportLooseVersion
# Add util to load path
basedir=os.path.abspath(os.path.dirname(sys.argv[0]))
sys.path.insert(0, os.path.join(basedir, 'util'))
# When running from HG repo, enable all warnings
DEVELOPER_MODE=os.path.exists(os.path.join(basedir, 'MANIFEST.in'))
ifDEVELOPER_MODE:
print('found MANIFEST.in, running in developer mode')
warnings.resetwarnings()
# We can't use `error`, because e.g. Sphinx triggers a
# DeprecationWarning.
warnings.simplefilter('default')
# Add src to load path, important for Sphinx autodoc
# to work properly
sys.path.insert(0, os.path.join(basedir, 'src'))
LLFUSE_VERSION='1.3.5'
defmain():
try:
fromsphinx.applicationimportSphinx#pylint: disable-msg=W0612
exceptImportError:
pass
else:
fix_docutils()
withopen(os.path.join(basedir, 'README.rst'), 'r') asfh:
long_desc=fh.read()
compile_args=pkg_config('fuse', cflags=True, ldflags=False, min_ver='2.8.0')
compile_args+= ['-DFUSE_USE_VERSION=29', '-Wall', '-Wextra', '-Wconversion',
'-Wsign-compare', '-DLLFUSE_VERSION="%s"'%LLFUSE_VERSION]
# We may have unused functions if we compile for older FUSE versions
compile_args.append('-Wno-unused-function')
# Nothing wrong with that if you know what you are doing
# (which Cython does)
compile_args.append('-Wno-implicit-fallthrough')
# Due to platform specific conditions, these are unavoidable
compile_args.append('-Wno-unused-parameter')
# Enable all fatal warnings only when compiling from Mercurial tip.
# (otherwise we break forward compatibility because compilation with newer
# compiler may fail if additional warnings are added)
ifDEVELOPER_MODE:
compile_args.append('-Werror')
compile_args.append('-Wfatal-errors')
# Unreachable code is expected because we need to support multiple
# platforms and architectures.
compile_args.append('-Wno-error=unreachable-code')
# Value-changing conversions should always be explicit.
compile_args.append('-Werror=conversion')
# Note that (i > -1) is false if i is unsigned (-1 will be converted to
# a large positive value). We certainly don't want to do this by
# accident.
compile_args.append('-Werror=sign-compare')
# http://bugs.python.org/issue7576
ifsys.version_info[0] ==3andsys.version_info[1] <2:
compile_args.append('-Wno-error=missing-field-initializers')
# http://bugs.python.org/issue969718
ifsys.version_info[0] ==2:
compile_args.append('-fno-strict-aliasing')
link_args=pkg_config('fuse', cflags=False, ldflags=True, min_ver='2.8.0')
link_args.append('-lpthread')
c_sources= ['src/llfuse.c', 'src/lock.c']
ifos.uname()[0] in ('Linux', 'GNU/kFreeBSD'):
link_args.append('-lrt')
elifos.uname()[0] =='Darwin':
c_sources.append('src/darwin_compat.c')
install_requires= []
ifsys.version_info[0] ==2:
install_requires.append('contextlib2')
setuptools.setup(
name='llfuse',
zip_safe=True,
version=LLFUSE_VERSION,
description='Python bindings for the low-level FUSE API',
long_description=long_desc,
author='Nikolaus Rath',
author_email='Nikolaus@rath.org',
url='https://bitbucket.org/nikratio/python-llfuse/',
download_url='https://bitbucket.org/nikratio/python-llfuse/downloads',
license='LGPL',
classifiers=['Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: System :: Filesystems',
'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',
'Operating System :: POSIX :: Linux',
'Operating System :: MacOS :: MacOS X',
'Operating System :: POSIX :: BSD :: FreeBSD'],
platforms=[ 'Linux', 'FreeBSD', 'OS X' ],
keywords=['FUSE', 'python' ],
package_dir={'': 'src'},
packages=setuptools.find_packages('src'),
provides=['llfuse'],
ext_modules=[Extension('llfuse', c_sources,
extra_compile_args=compile_args,
extra_link_args=link_args)],
cmdclass={'upload_docs': upload_docs,
'build_cython': build_cython },
command_options={
'build_sphinx': {
'version': ('setup.py', LLFUSE_VERSION),
'release': ('setup.py', LLFUSE_VERSION),
}},
install_requires=install_requires,
)
defpkg_config(pkg, cflags=True, ldflags=False, min_ver=None):
'''Frontend to ``pkg-config``'''
ifmin_ver:
cmd= ['pkg-config', pkg, '--atleast-version', min_ver ]
ifsubprocess.call(cmd) !=0:
cmd= ['pkg-config', '--modversion', pkg ]
proc=subprocess.Popen(cmd, stdout=subprocess.PIPE)
version=proc.communicate()[0].strip()
ifnotversion:
raiseSystemExit() # pkg-config generates error message already
else:
raiseSystemExit('%s version too old (found: %s, required: %s)'
% (pkg, version, min_ver))
cmd= ['pkg-config', pkg ]
ifcflags:
cmd.append('--cflags')
ifldflags:
cmd.append('--libs')
proc=subprocess.Popen(cmd, stdout=subprocess.PIPE)
cflags=proc.stdout.readline().rstrip()
proc.stdout.close()
ifproc.wait() !=0:
raiseSystemExit() # pkg-config generates error message already
returncflags.decode('us-ascii').split()
classupload_docs(setuptools.Command):
user_options= []
boolean_options= []
description="Upload documentation"
definitialize_options(self):
pass
deffinalize_options(self):
pass
defrun(self):
subprocess.check_call(['rsync', '-aHv', '--del', os.path.join(basedir, 'doc', 'html') +'/',
'ebox.rath.org:/srv/www.rath.org/llfuse-docs/'])
classbuild_cython(setuptools.Command):
user_options= []
boolean_options= []
description="Compile .pyx to .c"
definitialize_options(self):
pass
deffinalize_options(self):
self.extensions=self.distribution.ext_modules
defrun(self):
try:
version=subprocess.check_output(['cython', '--version'],
universal_newlines=True,
stderr=subprocess.STDOUT)
exceptOSError:
raiseSystemExit('Cython needs to be installed for this command')
hit=re.match('^Cython version (.+)$', version)
ifnothitorLooseVersion(hit.group(1)) <"0.24":
raiseSystemExit('Need Cython 0.24 or newer, found '+version)
cmd= ['cython', '-Wextra', '--force', '-3', '--fast-fail',
'--directive', 'embedsignature=True', '--include-dir',
os.path.join(basedir, 'Include'), '--verbose' ]
ifDEVELOPER_MODE:
cmd.append('-Werror')
# Work around http://trac.cython.org/cython_trac/ticket/714
cmd+= ['-X', 'warn.maybe_uninitialized=False' ]
forextensioninself.extensions:
forfile_inextension.sources:
(file_, ext) =os.path.splitext(file_)
path=os.path.join(basedir, file_)
ifext!='.c':
continue
ifos.path.exists(path+'.pyx'):
ifsubprocess.call(cmd+ [path+'.pyx']) !=0:
raiseSystemExit('Cython compilation failed')
deffix_docutils():
'''Work around https://bitbucket.org/birkenfeld/sphinx/issue/1154/'''
importdocutils.parsers
fromdocutils.parsersimportrst
old_getclass=docutils.parsers.get_parser_class
# Check if bug is there
try:
old_getclass('rst')
exceptAttributeError:
pass
else:
return
defget_parser_class(parser_name):
"""Return the Parser class from the `parser_name` module."""
ifparser_namein ('rst', 'restructuredtext'):
returnrst.Parser
else:
returnold_getclass(parser_name)
docutils.parsers.get_parser_class=get_parser_class
assertdocutils.parsers.get_parser_class('rst') isrst.Parser
if__name__=='__main__':
main()