PageRenderTime 26ms CodeModel.GetById 0ms RepoModel.GetById 1ms app.codeStats 0ms

/setup.py

https://bitbucket.org/excieve/pyhs/
Python | 74 lines | 60 code | 11 blank | 3 comment | 7 complexity | 58e0d15a01b8145fa00bd4b586b7ea32 MD5 | raw file
Possible License(s): MIT
  1. from setuptools import setup, Extension, Feature
  2. from distutils.command.build_ext import build_ext
  3. from distutils.errors import CCompilerError, DistutilsExecError,\
  4. DistutilsPlatformError
  5. # Optional C module building method taken from:
  6. # http://github.com/mitsuhiko/markupsafe/blob/master/setup.py
  7. speedups = Feature(
  8. 'optional C speed-enhancement module',
  9. standard=True,
  10. ext_modules = [
  11. Extension('pyhs._speedups', ['pyhs/_speedups.c']),
  12. ],
  13. )
  14. class BuildFailed(Exception):
  15. pass
  16. class ve_build_ext(build_ext):
  17. """This class allows C extension building to fail."""
  18. def run(self):
  19. try:
  20. build_ext.run(self)
  21. except DistutilsPlatformError:
  22. raise BuildFailed()
  23. def build_extension(self, ext):
  24. try:
  25. build_ext.build_extension(self, ext)
  26. except ext_errors:
  27. raise BuildFailed()
  28. def run_setup(with_binary):
  29. features = {}
  30. if with_binary:
  31. features['speedups'] = speedups
  32. setup(
  33. name = 'python-handler-socket',
  34. version = __import__('pyhs').__version__,
  35. url = 'http://bitbucket.org/excieve/pyhs',
  36. license = 'MIT',
  37. author = 'Artem Gluvchynsky',
  38. author_email='excieve@gmail.com',
  39. packages = ["pyhs"],
  40. long_description = open('README.rst').read(),
  41. description = 'HandlerSocket client for Python',
  42. platforms = 'any',
  43. classifiers = [
  44. 'Development Status :: 3 - Alpha',
  45. 'Environment :: Console',
  46. 'Environment :: Web Environment',
  47. 'Intended Audience :: Developers',
  48. 'License :: OSI Approved :: MIT License',
  49. 'Operating System :: OS Independent',
  50. 'Programming Language :: Python',
  51. 'Topic :: Software Development :: Libraries',
  52. 'Topic :: Database',
  53. ],
  54. cmdclass={'build_ext': ve_build_ext},
  55. features=features,
  56. )
  57. try:
  58. run_setup(True)
  59. except BuildFailed:
  60. print 'The C extension could not be compiled, speedups are not enabled.'
  61. print 'Trying to build without C extension now.'
  62. run_setup(False)
  63. print 'Success.'