summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2014-04-29 12:20:33 +0300
committerKai Huuhko <kai.huuhko@gmail.com>2014-04-29 12:20:33 +0300
commitfdfa113926756f17551d75bc9ead87fb570480c2 (patch)
tree0fd4bee6fd2d3671f7116984d9124be478796d59
parent69345c82d69a8b57026dacc6a71906fc4b56faa0 (diff)
setup.py: pep-8 cleanup
-rwxr-xr-xsetup.py311
1 files changed, 177 insertions, 134 deletions
diff --git a/setup.py b/setup.py
index 897dcf4..44ee4ec 100755
--- a/setup.py
+++ b/setup.py
@@ -32,11 +32,18 @@ try:
32 from sphinx.setup_command import BuildDoc 32 from sphinx.setup_command import BuildDoc
33except ImportError: 33except ImportError:
34 class BuildDoc(Command): 34 class BuildDoc(Command):
35 description = "build documentation using sphinx, that must be installed." 35 description = \
36 "build documentation using sphinx, that must be installed."
36 user_options = [] 37 user_options = []
37 def initialize_options(self): pass 38
38 def finalize_options(self): pass 39 def initialize_options(self):
39 def run(self): print("Error: sphinx not found") 40 pass
41
42 def finalize_options(self):
43 pass
44
45 def run(self):
46 print("Error: sphinx not found")
40 47
41 48
42# === pkg-config === 49# === pkg-config ===
@@ -71,7 +78,9 @@ def pkg_config(name, require, min_vers=None):
71 except (OSError, subprocess.CalledProcessError): 78 except (OSError, subprocess.CalledProcessError):
72 raise SystemExit("Did not find " + name + " with 'pkg-config'.") 79 raise SystemExit("Did not find " + name + " with 'pkg-config'.")
73 except (AssertionError): 80 except (AssertionError):
74 raise SystemExit(name+" version mismatch. Found: "+ver+" Needed: "+min_vers) 81 raise SystemExit(
82 name + " version mismatch. Found: " + ver + " Needed: " + min_vers
83 )
75 84
76 85
77# use cython or pre-generated c files 86# use cython or pre-generated c files
@@ -84,31 +93,41 @@ if os.path.exists(os.path.join(script_path, "efl", "eo", "efl.eo.pyx")):
84 from Cython.Build import cythonize 93 from Cython.Build import cythonize
85 import Cython.Compiler.Options 94 import Cython.Compiler.Options
86 except ImportError: 95 except ImportError:
87 raise SystemExit("Requires Cython >= %s (http://cython.org/)" % CYTHON_MIN_VERSION) 96 raise SystemExit(
97 "Requires Cython >= %s (http://cython.org/)" % CYTHON_MIN_VERSION
98 )
88 99
89 try: 100 try:
90 try: 101 try:
91 assert StrictVersion(Cython.__version__) >= StrictVersion(CYTHON_MIN_VERSION) 102 assert StrictVersion(Cython.__version__) >= \
103 StrictVersion(CYTHON_MIN_VERSION)
92 except ValueError: 104 except ValueError:
93 print("Your Cython version string (%s) is weird. We'll attempt to " 105 print(
94 "check that it's higher than the minimum required: %s, but this " 106 "Your Cython version string (%s) is weird. We'll attempt to "
95 "is unreliable.\n" 107 "check that it's higher than the minimum required: %s, but "
96 "If you run into any problems during or after installation it may " 108 "this is unreliable.\n"
97 "be caused by version of Cython that's too old." % ( 109 "If you run into any problems during or after installation it "
110 "may be caused by version of Cython that's too old." % (
98 Cython.__version__, CYTHON_MIN_VERSION 111 Cython.__version__, CYTHON_MIN_VERSION
99 )
100 ) 112 )
101 assert LooseVersion(Cython.__version__) >= LooseVersion(CYTHON_MIN_VERSION) 113 )
114 assert LooseVersion(Cython.__version__) >= \
115 LooseVersion(CYTHON_MIN_VERSION)
102 except AssertionError: 116 except AssertionError:
103 raise SystemExit("Requires Cython >= %s (http://cython.org/)" % CYTHON_MIN_VERSION) 117 raise SystemExit(
118 "Requires Cython >= %s (http://cython.org/)" % CYTHON_MIN_VERSION
119 )
104 120
105 Cython.Compiler.Options.fast_fail = True # Stop compilation on first error 121 Cython.Compiler.Options.fast_fail = True # Stop compilation on first error
106 Cython.Compiler.Options.annotate = False # Generates HTML files with annotated source 122 Cython.Compiler.Options.annotate = False # Generates HTML files with
107 Cython.Compiler.Options.docstrings = True # Set to False to disable docstrings 123 # annotated source
124 Cython.Compiler.Options.docstrings = True # Set to False to disable
125 # docstrings
108 126
109else: 127else:
110 module_suffix = ".c" 128 module_suffix = ".c"
111 from distutils.command.build_ext import build_ext 129 from distutils.command.build_ext import build_ext
130
112 def cythonize(modules, *args, **kwargs): 131 def cythonize(modules, *args, **kwargs):
113 return modules 132 return modules
114 133
@@ -116,16 +135,24 @@ else:
116class CleanGenerated(Command): 135class CleanGenerated(Command):
117 description = "Clean C and html files generated by Cython" 136 description = "Clean C and html files generated by Cython"
118 user_options = [] 137 user_options = []
119 def initialize_options(self): pass 138
120 def finalize_options(self): pass 139 def initialize_options(self):
140 pass
141
142 def finalize_options(self):
143 pass
144
121 def run(self): 145 def run(self):
122 for lib in "eo", "evas", "ecore", "edje", "edje/edit", "emotion", "elementary", "utils": 146 for lib in ("eo", "evas", "ecore", "edje", "edje/edit", "emotion",
123 for root, dirs, files in os.walk(os.path.join(script_path, "efl", lib)): 147 "elementary", "utils"):
148 for root, dirs, files in \
149 os.walk(os.path.join(script_path, "efl", lib)):
124 for f in files: 150 for f in files:
125 if f.endswith(".c") or f.endswith(".html"): 151 if f.endswith(".c") or f.endswith(".html"):
126 path = os.path.join(root, f) 152 path = os.path.join(root, f)
127 os.remove(path) 153 os.remove(path)
128 dbus_ml_path = os.path.join(script_path, "efl", "dbus_mainloop", "dbus_mainloop.c") 154 dbus_ml_path = os.path.join(
155 script_path, "efl", "dbus_mainloop", "dbus_mainloop.c")
129 if os.path.exists(dbus_ml_path): 156 if os.path.exists(dbus_ml_path):
130 os.remove(dbus_ml_path) 157 os.remove(dbus_ml_path)
131 158
@@ -139,94 +166,100 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
139 # === Eina === 166 # === Eina ===
140 eina_cflags, eina_libs = pkg_config('Eina', 'eina', EFL_MIN_VERSION) 167 eina_cflags, eina_libs = pkg_config('Eina', 'eina', EFL_MIN_VERSION)
141 168
142
143 # === Eo === 169 # === Eo ===
144 eo_cflags, eo_libs = pkg_config('Eo', 'eo', EFL_MIN_VERSION) 170 eo_cflags, eo_libs = pkg_config('Eo', 'eo', EFL_MIN_VERSION)
145 eo_ext = Extension("eo", ["efl/eo/efl.eo"+module_suffix], 171 eo_ext = Extension(
146 define_macros = [('EFL_BETA_API_SUPPORT', None)], 172 "eo", ["efl/eo/efl.eo" + module_suffix],
147 include_dirs = ['include/'], 173 define_macros=[('EFL_BETA_API_SUPPORT', None)],
148 extra_compile_args = eo_cflags, 174 include_dirs=['include/'],
149 extra_link_args = eo_libs + eina_libs 175 extra_compile_args=eo_cflags,
150 ) 176 extra_link_args=eo_libs + eina_libs
177 )
151 modules.append(eo_ext) 178 modules.append(eo_ext)
152 179
153
154 # === Utilities === 180 # === Utilities ===
155 utils_ext = [ 181 utils_ext = [
156 Extension("utils.deprecated", ["efl/utils/deprecated"+module_suffix], 182 Extension(
157 include_dirs = ['include/'], 183 "utils.deprecated", ["efl/utils/deprecated" + module_suffix],
158 extra_compile_args = eina_cflags, 184 include_dirs=['include/'],
159 extra_link_args = eina_libs 185 extra_compile_args=eina_cflags,
160 ), 186 extra_link_args=eina_libs
161 Extension("utils.conversions", ["efl/utils/conversions"+module_suffix], 187 ),
162 include_dirs = ['include/'], 188 Extension(
163 extra_compile_args = eo_cflags, 189 "utils.conversions", ["efl/utils/conversions" + module_suffix],
164 extra_link_args = eo_libs + eina_libs, 190 include_dirs=['include/'],
165 ), 191 extra_compile_args=eo_cflags,
166 Extension("utils.logger", ["efl/utils/logger"+module_suffix], 192 extra_link_args=eo_libs + eina_libs,
167 include_dirs = ['include/'], 193 ),
168 extra_compile_args = eina_cflags, 194 Extension(
169 extra_link_args = eina_libs, 195 "utils.logger", ["efl/utils/logger" + module_suffix],
170 ), 196 include_dirs=['include/'],
171 ] 197 extra_compile_args=eina_cflags,
198 extra_link_args=eina_libs,
199 ),
200 ]
172 modules += utils_ext 201 modules += utils_ext
173 packages.append("efl.utils") 202 packages.append("efl.utils")
174 203
175
176 # === Evas === 204 # === Evas ===
177 evas_cflags, evas_libs = pkg_config('Evas', 'evas', EFL_MIN_VERSION) 205 evas_cflags, evas_libs = pkg_config('Evas', 'evas', EFL_MIN_VERSION)
178 evas_ext = Extension("evas", ["efl/evas/efl.evas"+module_suffix], 206 evas_ext = Extension(
179 include_dirs = ['include/'], 207 "evas", ["efl/evas/efl.evas" + module_suffix],
180 extra_compile_args = evas_cflags, 208 include_dirs=['include/'],
181 extra_link_args = evas_libs + eina_libs, 209 extra_compile_args=evas_cflags,
182 ) 210 extra_link_args=evas_libs + eina_libs,
211 )
183 modules.append(evas_ext) 212 modules.append(evas_ext)
184 213
185 # compatibility 214 # compatibility
186 packages.append("evas") 215 packages.append("evas")
187 package_dirs["evas"] = "compat/evas" 216 package_dirs["evas"] = "compat/evas"
188 217
189
190 # === Ecore === 218 # === Ecore ===
191 ecore_cflags, ecore_libs = pkg_config('Ecore', 'ecore', EFL_MIN_VERSION) 219 ecore_cflags, ecore_libs = pkg_config('Ecore', 'ecore', EFL_MIN_VERSION)
192 ecore_file_cflags, ecore_file_libs = pkg_config('EcoreFile', 'ecore-file', "1.8.0") 220 ecore_file_cflags, ecore_file_libs = pkg_config(
193 ecore_ext = Extension("ecore", ["efl/ecore/efl.ecore"+module_suffix], 221 'EcoreFile', 'ecore-file', EFL_MIN_VERSION)
194 include_dirs = ['include/'], 222 ecore_ext = Extension(
195 extra_compile_args = list(set(ecore_cflags + ecore_file_cflags)), 223 "ecore", ["efl/ecore/efl.ecore" + module_suffix],
196 extra_link_args = ecore_libs + ecore_file_libs + eina_libs + evas_libs, 224 include_dirs=['include/'],
197 ) 225 extra_compile_args=list(set(ecore_cflags + ecore_file_cflags)),
226 extra_link_args=ecore_libs + ecore_file_libs + eina_libs + evas_libs,
227 )
198 modules.append(ecore_ext) 228 modules.append(ecore_ext)
199 229
200 # compatibility 230 # compatibility
201 packages.append("ecore") 231 packages.append("ecore")
202 package_dirs["ecore"] = "compat/ecore" 232 package_dirs["ecore"] = "compat/ecore"
203 233
204
205 # === Ethumb === 234 # === Ethumb ===
206 ethumb_cflags, ethumb_libs = pkg_config('Ethumb', 'ethumb', EFL_MIN_VERSION) 235 ethumb_cflags, ethumb_libs = pkg_config(
207 ethumb_ext = Extension("ethumb", ["efl/ethumb/efl.ethumb"+module_suffix], 236 'Ethumb', 'ethumb', EFL_MIN_VERSION)
208 include_dirs = ['include/'], 237 ethumb_ext = Extension(
209 extra_compile_args = ethumb_cflags, 238 "ethumb", ["efl/ethumb/efl.ethumb" + module_suffix],
210 extra_link_args = ethumb_libs + eina_libs, 239 include_dirs=['include/'],
211 ) 240 extra_compile_args=ethumb_cflags,
241 extra_link_args=ethumb_libs + eina_libs,
242 )
212 modules.append(ethumb_ext) 243 modules.append(ethumb_ext)
213 244
214 ethumb_client_cflags, ethumb_client_libs = pkg_config('Ethumb_Client', 'ethumb_client', EFL_MIN_VERSION) 245 ethumb_client_cflags, ethumb_client_libs = pkg_config(
215 ethumb_client_ext = Extension("ethumb_client", ["efl/ethumb/efl.ethumb_client"+module_suffix], 246 'Ethumb_Client', 'ethumb_client', EFL_MIN_VERSION)
216 include_dirs = ['include/'], 247 ethumb_client_ext = Extension(
217 extra_compile_args = ethumb_client_cflags, 248 "ethumb_client", ["efl/ethumb/efl.ethumb_client" + module_suffix],
218 extra_link_args = ethumb_client_libs + eina_libs, 249 include_dirs=['include/'],
219 ) 250 extra_compile_args=ethumb_client_cflags,
251 extra_link_args=ethumb_client_libs + eina_libs,
252 )
220 modules.append(ethumb_client_ext) 253 modules.append(ethumb_client_ext)
221 254
222
223 # === Edje === 255 # === Edje ===
224 edje_cflags, edje_libs = pkg_config('Edje', 'edje', EFL_MIN_VERSION) 256 edje_cflags, edje_libs = pkg_config('Edje', 'edje', EFL_MIN_VERSION)
225 edje_ext = Extension("edje", ["efl/edje/efl.edje"+module_suffix], 257 edje_ext = Extension(
226 include_dirs = ['include/'], 258 "edje", ["efl/edje/efl.edje" + module_suffix],
227 extra_compile_args = edje_cflags, 259 include_dirs=['include/'],
228 extra_link_args = edje_libs + eina_libs + evas_libs, 260 extra_compile_args=edje_cflags,
229 ) 261 extra_link_args=edje_libs + eina_libs + evas_libs,
262 )
230 modules.append(edje_ext) 263 modules.append(edje_ext)
231 264
232 # compatibility 265 # compatibility
@@ -234,44 +267,46 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
234 package_dirs["edje"] = "compat/edje" 267 package_dirs["edje"] = "compat/edje"
235 268
236 # --- Edje_Edit --- 269 # --- Edje_Edit ---
237 edje_edit_ext = Extension("edje_edit", ["efl/edje/efl.edje_edit"+module_suffix], 270 edje_edit_ext = Extension(
238 define_macros = [('EDJE_EDIT_IS_UNSTABLE_AND_I_KNOW_ABOUT_IT', None)], 271 "edje_edit", ["efl/edje/efl.edje_edit" + module_suffix],
239 include_dirs = ['include/'], 272 define_macros=[('EDJE_EDIT_IS_UNSTABLE_AND_I_KNOW_ABOUT_IT', None)],
240 extra_compile_args = edje_cflags, 273 include_dirs=['include/'],
241 extra_link_args = edje_libs + eina_libs + evas_libs, 274 extra_compile_args=edje_cflags,
242 ) 275 extra_link_args=edje_libs + eina_libs + evas_libs,
276 )
243 modules.append(edje_edit_ext) 277 modules.append(edje_edit_ext)
244 278
245
246 # === Emotion === 279 # === Emotion ===
247 emotion_cflags, emotion_libs = pkg_config('Emotion', 'emotion', EFL_MIN_VERSION) 280 emotion_cflags, emotion_libs = pkg_config(
248 emotion_ext = Extension("emotion", ["efl/emotion/efl.emotion"+module_suffix], 281 'Emotion', 'emotion', EFL_MIN_VERSION)
249 include_dirs = ['include/'], 282 emotion_ext = Extension(
250 extra_compile_args = emotion_cflags, 283 "emotion", ["efl/emotion/efl.emotion" + module_suffix],
251 extra_link_args = emotion_libs + eina_libs + evas_libs, 284 include_dirs=['include/'],
252 ) 285 extra_compile_args=emotion_cflags,
286 extra_link_args=emotion_libs +
287 eina_libs + evas_libs,
288 )
253 modules.append(emotion_ext) 289 modules.append(emotion_ext)
254 290
255 # compatibility 291 # compatibility
256 packages.append("emotion") 292 packages.append("emotion")
257 package_dirs["emotion"] = "compat/emotion" 293 package_dirs["emotion"] = "compat/emotion"
258 294
259
260 # === dbus mainloop integration === 295 # === dbus mainloop integration ===
261 dbus_cflags, dbus_libs = pkg_config('DBus', 'dbus-python', "0.83.0") 296 dbus_cflags, dbus_libs = pkg_config('DBus', 'dbus-python', "0.83.0")
262 dbus_ml_ext = Extension("dbus_mainloop", 297 dbus_ml_ext = Extension(
263 ["efl/dbus_mainloop/dbus_mainloop"+module_suffix, 298 "dbus_mainloop",
264 "efl/dbus_mainloop/e_dbus.c"], 299 ["efl/dbus_mainloop/dbus_mainloop" + module_suffix,
265 extra_compile_args = list(set(dbus_cflags + ecore_cflags)), 300 "efl/dbus_mainloop/e_dbus.c"],
266 extra_link_args = dbus_libs + ecore_libs, 301 extra_compile_args=list(set(dbus_cflags + ecore_cflags)),
267 ) 302 extra_link_args=dbus_libs + ecore_libs,
303 )
268 modules.append(dbus_ml_ext) 304 modules.append(dbus_ml_ext)
269 305
270 # compatibility 306 # compatibility
271 packages.append("e_dbus") 307 packages.append("e_dbus")
272 package_dirs["e_dbus"] = "compat/e_dbus" 308 package_dirs["e_dbus"] = "compat/e_dbus"
273 309
274
275 # === Elementary === 310 # === Elementary ===
276 elm_mods = ( 311 elm_mods = (
277 #"access", 312 #"access",
@@ -347,14 +382,16 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
347 "window", 382 "window",
348 ) 383 )
349 384
350 elm_cflags, elm_libs = pkg_config('Elementary', 'elementary', ELM_MIN_VERSION) 385 elm_cflags, elm_libs = pkg_config(
386 'Elementary', 'elementary', ELM_MIN_VERSION)
351 for m in elm_mods: 387 for m in elm_mods:
352 e = Extension("elementary." + m, 388 e = Extension(
353 ["efl/elementary/" + m + module_suffix], 389 "elementary." + m,
354 include_dirs = ["include/"], 390 ["efl/elementary/" + m + module_suffix],
355 extra_compile_args = elm_cflags, 391 include_dirs=["include/"],
356 extra_link_args = elm_libs + eina_libs + evas_libs, 392 extra_compile_args=elm_cflags,
357 ) 393 extra_link_args=elm_libs + eina_libs + evas_libs,
394 )
358 modules.append(e) 395 modules.append(e)
359 396
360 packages.append("efl.elementary") 397 packages.append("efl.elementary")
@@ -365,37 +402,43 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
365 402
366 403
367setup( 404setup(
368 name = "python-efl", 405 name="python-efl",
369 fullname = "Python bindings for Enlightenment Foundation Libraries", 406 fullname="Python bindings for Enlightenment Foundation Libraries",
370 description = "Python bindings for Enlightenment Foundation Libraries", 407 description="Python bindings for Enlightenment Foundation Libraries",
371 version = RELEASE, 408 version=RELEASE,
372 author = "Gustavo Sverzut Barbieri, Simon Busch, Boris 'billiob' Faure, Davide Andreoli, Fabiano Fidêncio, Bruno Dilly, Tiago Falcão, Joost Albers, Kai Huuhko, Ulisses Furquim", 409 author=(
373 author_email = "dave@gurumeditation.it, kai.huuhko@gmail.com", 410 "Gustavo Sverzut Barbieri, Simon Busch, Boris 'billiob' Faure, "
374 maintainer = "Kai Huuhko, Davide Andreoli", 411 "Davide Andreoli, Fabiano Fidêncio, Bruno Dilly, Tiago Falcão, "
375 maintainer_email = "kai.huuhko@gmail.com, dave@gurumeditation.it", 412 "Joost Albers, Kai Huuhko, Ulisses Furquim"
376 contact = "Enlightenment developer mailing list", 413 ),
377 contact_email = "enlightenment-devel@lists.sourceforge.net", 414 author_email="dave@gurumeditation.it, kai.huuhko@gmail.com",
378 url = "http://www.enlightenment.org", 415 maintainer="Kai Huuhko, Davide Andreoli",
379 license = "GNU Lesser General Public License (LGPL)", 416 maintainer_email="kai.huuhko@gmail.com, dave@gurumeditation.it",
380 cmdclass = { 417 contact="Enlightenment developer mailing list",
418 contact_email="enlightenment-devel@lists.sourceforge.net",
419 url="http://www.enlightenment.org",
420 license="GNU Lesser General Public License (LGPL)",
421 cmdclass={
381 'build_ext': build_ext, 422 'build_ext': build_ext,
382 'build_doc': BuildDoc, 423 'build_doc': BuildDoc,
383 'clean_generated_files': CleanGenerated 424 'clean_generated_files': CleanGenerated
384 }, 425 },
385 command_options = { 426 command_options={
386 'build_doc': { 427 'build_doc': {
387 'version': ('setup.py', VERSION), 428 'version': ('setup.py', VERSION),
388 'release': ('setup.py', RELEASE) 429 'release': ('setup.py', RELEASE)
389 } 430 }
390 }, 431 },
391 package_dir = package_dirs, 432 package_dir=package_dirs,
392 packages = packages, 433 packages=packages,
393 ext_package = "efl", # The prefix for ext modules/packages 434 ext_package="efl", # The prefix for ext modules/packages
394 ext_modules = cythonize(modules, include_path=["include"], 435 ext_modules=cythonize(
395 compiler_directives={ 436 modules,
396 #"c_string_type": "unicode", 437 include_path=["include"],
397 #"c_string_encoding": "utf-8", 438 compiler_directives={
398 "embedsignature": True, 439 #"c_string_type": "unicode",
399 } 440 #"c_string_encoding": "utf-8",
400 ), 441 "embedsignature": True,
442 }
443 ),
401) 444)