root/trunk/setup.py @ 26655

Revision 26655, 3.0 KB (checked in by glyph, 17 months ago)

Revert r26654 - accidentally mis-merged (added files were not committed)

Reopens #1696

  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2
3# Copyright (c) 2001-2009 Twisted Matrix Laboratories.
4# See LICENSE for details.
5
6"""
7Distutils installer for Twisted.
8"""
9
10try:
11    # Load setuptools, to build a specific source package
12    import setuptools
13except ImportError:
14    pass
15
16import sys, os
17
18
19def 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
38def 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
47
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))
55
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="""\
69An extensible framework for Python programming, with special focus
70on event-based network programming and multiprotocol integration.
71""",
72            packages = getPackages('twisted'),
73            conditionalExtensions = getExtensions(),
74            scripts = scripts,
75            data_files=getDataFiles('twisted'),
76            )
77
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.
85This version of setuptools has a bug parsing dependencies, so automatic
86dependency 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)
93
94
95if __name__ == "__main__":
96    try:
97        main(sys.argv[1:])
98    except KeyboardInterrupt:
99        sys.exit(1)
Note: See TracBrowser for help on using the browser.