Ticket #1286: patch.diff.txt

File patch.diff.txt, 5.7 kB (added by zooko, 1 year ago)
Line 
1 Index: twisted/python/dist.py
2 ===================================================================
3 --- twisted/python/dist.py      (revision 21829)
4 +++ twisted/python/dist.py      (working copy)
5 @@ -321,6 +321,6 @@
6          try:
7              build_ext.build_ext.build_extension(self, ext)
8          except CCompilerError, x:
9 -            print '*'*70+'\n'
10 +            print '*' * 70 + '\n'
11              print "Failed to build extension, continue"
12 -            print '*'*70+'\n'
13 +            print '*' * 70 + '\n'
14 Index: setup.py
15 ===================================================================
16 --- setup.py    (revision 21829)
17 +++ setup.py    (working copy)
18 @@ -3,6 +3,10 @@
19  # Copyright (c) 2001-2007 Twisted Matrix Laboratories.
20  # See LICENSE for details.
21  
22 +"""
23 +Setup script for the overall Twisted library.
24 +"""
25 +
26  import sys, os
27  
28  
29 @@ -46,11 +50,15 @@
30          scripts=scripts,
31      )
32      if 'setuptools' in sys.modules:
33 -        setup_args['install_requires'] = ['zope.interface']
34 +        setup_args['install_requires']=['zope.interface']
35      dist.setup(**setup_args)
36  
37  
38  if __name__ == "__main__":
39 +    """
40 +    I invoke twisted.python.dist with the appropriate metadata about the
41 +    Twisted package.
42 +    """
43      try:
44          main(sys.argv[1:])
45      except KeyboardInterrupt:
46 Index: setupdist.py
47 ===================================================================
48 --- setupdist.py        (revision 21829)
49 +++ setupdist.py        (working copy)
50 @@ -1,134 +0,0 @@
51 -#!/usr/bin/env python
52 -
53 -# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
54 -# See LICENSE for details.
55 -
56 -"""
57 -Distutils-launcher for Twisted projects.
58 -
59 -This is a script which emulates a distutils-style setup.py, by delegating its
60 -invocation arguments to actual distutils setup.py scripts for each Twisted
61 -subproject in turn.
62 -
63 -It locates other setup.py scripts by detecting whether it is run in a 'sumo'
64 -configuration, which is the structure of the released tarballs, or a 'non-sumo'
65 -(development) configuration, which is the structure of the SVN repository.
66 -"""
67 -
68 -import sys, os, glob
69 -
70 -sumoSubprojects = ['core', 'conch', 'lore', 'mail', 'names',
71 -                   'runner', 'web', 'words', 'news']
72 -
73 -specialPaths = {'core': 'twisted/topfiles/setup.py'}
74 -
75 -
76 -def runInDir(dir, f, *args, **kw):
77 -    """
78 -    Run a function after chdiring to a directory, and chdir back to
79 -    the original directory afterwards, even if the function fails.
80 -    """
81 -    origdir = os.path.abspath('.')
82 -    os.chdir(dir)
83 -    try:
84 -        return f(*args, **kw)
85 -    finally:
86 -        os.chdir(origdir)
87 -
88 -
89 -def getSumoProjDir(proj):
90 -    """
91 -    Return the existing directory which contains the specified
92 -    subproject. If no applicable directory is found, None is returned
93 -    (which may be because we are not running from a Sumo tarball). If
94 -    more than one appropriate directory is found, an AssertionError is
95 -    raised.
96 -    """
97 -    globst = 'Twisted%s-*' % proj.capitalize()
98 -    gl = glob.glob(globst)
99 -    assert not len(gl) > 1, 'Wrong number of %s directories found!?' % (proj,)
100 -    if gl:
101 -        return gl[0]
102 -
103 -
104 -def findSetupPy(project):
105 -    """
106 -    Try to find a setup.py file, and quit the process if none is found.
107 -    @returns: tuple of (setup.py path,  sumoMode), where sumoMode is a boolean.
108 -    """
109 -    tried = []
110 -
111 -    setupPy = specialPaths.get(project)
112 -    tried.append(setupPy)
113 -    if setupPy and os.path.exists(setupPy):
114 -        return (setupPy, False)
115 -
116 -    setupPy = os.path.join('twisted', project, 'topfiles', 'setup.py')
117 -    tried.append(setupPy)
118 -    if os.path.exists(setupPy):
119 -        return (setupPy, False)
120 -
121 -    projdir = getSumoProjDir(project)
122 -    if projdir:
123 -        setupPy = os.path.join(projdir, 'setup.py')
124 -        tried.append(setupPy)
125 -        if os.path.exists(setupPy):
126 -            return (setupPy, True)
127 -
128 -    sys.stderr.write("Error: No such project '%s'.\n" % (project,))
129 -    sys.stderr.write(" (%s not found)\n" % (tried,))
130 -    sys.exit(1)
131 -
132 -def runSetup(project, args):
133 -    setupPy, sumoMode = findSetupPy(project)
134 -
135 -    # Packaged setup.py files want to be run in the root directory of
136 -    # their source, whereas out of SVN they should be run from the
137 -    # root directory of the entire tree.
138 -    if sumoMode:
139 -        result = runInDir(os.path.dirname(setupPy), os.spawnv,
140 -                          os.P_WAIT, sys.executable,
141 -                          [sys.executable, 'setup.py'] + args)
142 -    else:
143 -        result = os.spawnv(os.P_WAIT, sys.executable,
144 -                           [sys.executable, setupPy] + args)
145 -
146 -    if result != 0:
147 -        sys.stderr.write(
148 -            "Error: Subprocess exited with result %d for project %s\n" %
149 -            (result, project))
150 -        sys.exit(1)
151 -
152 -
153 -def main(args):
154 -    """
155 -    Delegate setup.py functionality to individual subproject setup.py scripts.
156 -
157 -    If we are running from a Sumo tarball, the TwistedCore-* directory
158 -    will be added to PYTHONPATH so setup.py scripts can use
159 -    functionality from Twisted.
160 -    """
161 -    os.environ["PYTHONPATH"] = "." + os.pathsep + os.getenv("PYTHONPATH", "")
162 -    if len(args) == 0 or args[0] in ('-h', '--help'):
163 -        sys.stdout.write(
164 -"""Twisted: The Framework Of Your Internet.
165 -Usage: setup.py <distutils args..>
166 -""")
167 -        runSetup('core', ['-h'])
168 -        sys.exit(0)
169 -
170 -    # If we've got a sumo ball, we should insert the Core directory
171 -    # into sys.path because setup.py files try to import
172 -    # twisted.python.dist.
173 -    coredir = getSumoProjDir("core")
174 -    if coredir and os.path.exists(coredir):
175 -        os.environ["PYTHONPATH"] += os.pathsep + os.path.abspath(coredir)
176 -
177 -    for project in sumoSubprojects:
178 -        runSetup(project, args)
179 -
180 -if __name__ == "__main__":
181 -    try:
182 -        main(sys.argv[1:])
183 -    except KeyboardInterrupt:
184 -        sys.exit(1)