setup.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/usr/bin/python
  2. # Copyright (c) 2001-2008 Twisted Matrix Laboratories.
  3. # See LICENSE for details.
  4. """
  5. Distutils installer for Twisted.
  6. """
  7. try:
  8. # Load setuptools, to build a specific source package
  9. import setuptools
  10. except ImportError:
  11. pass
  12. import sys, os
  13. def getExtensions():
  14. """
  15. Get all extensions from core and all subprojects.
  16. """
  17. extensions = []
  18. if not sys.platform.startswith('java'):
  19. for dir in os.listdir("twisted") + [""]:
  20. topfiles = os.path.join("twisted", dir, "topfiles")
  21. if os.path.isdir(topfiles):
  22. ns = {}
  23. setup_py = os.path.join(topfiles, "setup.py")
  24. execfile(setup_py, ns, ns)
  25. if "extensions" in ns:
  26. extensions.extend(ns["extensions"])
  27. return extensions
  28. def main(args):
  29. """
  30. Invoke twisted.python.dist with the appropriate metadata about the
  31. Twisted package.
  32. """
  33. if os.path.exists('twisted'):
  34. sys.path.insert(0, '.')
  35. from twisted import copyright
  36. from twisted.python.dist import getDataFiles, getScripts, getPackages, setup
  37. # "" is included because core scripts are directly in bin/
  38. projects = [''] + [x for x in os.listdir('bin')
  39. if os.path.isdir(os.path.join("bin", x))
  40. and not x.startswith(".")]
  41. scripts = []
  42. for i in projects:
  43. scripts.extend(getScripts(i))
  44. setup_args = dict(
  45. # metadata
  46. name="Twisted",
  47. version=copyright.version,
  48. description="An asynchronous networking framework written in "
  49. "Python",
  50. author="Twisted Matrix Laboratories",
  51. author_email="twisted-python@twistedmatrix.com",
  52. maintainer="Glyph Lefkowitz",
  53. maintainer_email="glyph@twistedmatrix.com",
  54. url="http://twistedmatrix.com/",
  55. license="MIT",
  56. long_description="""\
  57. An extensible framework for Python programming, with special focus
  58. on event-based network programming and multiprotocol integration.
  59. """,
  60. packages = getPackages('twisted'),
  61. conditionalExtensions = getExtensions(),
  62. scripts = scripts,
  63. data_files=getDataFiles('twisted'),
  64. )
  65. if 'setuptools' in sys.modules:
  66. from pkg_resources import parse_requirements
  67. requirements = ["zope.interface"]
  68. try:
  69. list(parse_requirements(requirements))
  70. except:
  71. print """You seem to be running a very old version of setuptools.
  72. This version of setuptools has a bug parsing dependencies, so automatic
  73. dependency resolution is disabled.
  74. """
  75. else:
  76. setup_args['install_requires'] = requirements
  77. setup_args['include_package_data'] = True
  78. setup_args['zip_safe'] = False
  79. setup(**setup_args)
  80. if __name__ == "__main__":
  81. try:
  82. main(sys.argv[1:])
  83. except KeyboardInterrupt:
  84. sys.exit(1)