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