Imported Upstream version 12.1.0
[contrib/python-twisted.git] / setup.py
1 #!/usr/bin/env python
2
3 # Copyright (c) Twisted Matrix Laboratories.
4 # See LICENSE for details.
5
6 """
7 Distutils installer for Twisted.
8 """
9
10 try:
11     # Load setuptools, to build a specific source package
12     import setuptools
13 except ImportError:
14     pass
15
16 import sys, os
17
18
19 def getExtensions():
20     """
21     Get all extensions from core and all subprojects.
22     """
23     extensions = []
24
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"])
34
35     return extensions
36
37
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, \
47                                     setup, twisted_subprojects
48
49     # "" is included because core scripts are directly in bin/
50     projects = [''] + [x for x in os.listdir('bin')
51                        if os.path.isdir(os.path.join("bin", x))
52                        and x in twisted_subprojects]
53
54     scripts = []
55     for i in projects:
56         scripts.extend(getScripts(i))
57
58     setup_args = dict(
59         # metadata
60         name="Twisted",
61         version=copyright.version,
62         description="An asynchronous networking framework written in Python",
63         author="Twisted Matrix Laboratories",
64         author_email="twisted-python@twistedmatrix.com",
65         maintainer="Glyph Lefkowitz",
66         maintainer_email="glyph@twistedmatrix.com",
67         url="http://twistedmatrix.com/",
68         license="MIT",
69         long_description="""\
70 An extensible framework for Python programming, with special focus
71 on event-based network programming and multiprotocol integration.
72 """,
73         packages = getPackages('twisted'),
74         conditionalExtensions = getExtensions(),
75         scripts = scripts,
76         data_files=getDataFiles('twisted'),
77         classifiers=[
78             "Programming Language :: Python :: 2.5",
79             "Programming Language :: Python :: 2.6",
80             "Programming Language :: Python :: 2.7",
81             ])
82
83     if 'setuptools' in sys.modules:
84         from pkg_resources import parse_requirements
85         requirements = ["zope.interface"]
86         try:
87             list(parse_requirements(requirements))
88         except:
89             print """You seem to be running a very old version of setuptools.
90 This version of setuptools has a bug parsing dependencies, so automatic
91 dependency resolution is disabled.
92 """
93         else:
94             setup_args['install_requires'] = requirements
95         setup_args['include_package_data'] = True
96         setup_args['zip_safe'] = False
97     setup(**setup_args)
98
99
100 if __name__ == "__main__":
101     try:
102         main(sys.argv[1:])
103     except KeyboardInterrupt:
104         sys.exit(1)
105