| 1 | Index: twisted/python/dist.py |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- twisted/python/dist.py (revision 21904) |
|---|
| 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 21904) |
|---|
| 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 | +Distutils installer for Twisted. |
|---|
| 24 | +""" |
|---|
| 25 | + |
|---|
| 26 | import sys, os |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | @@ -19,38 +23,23 @@ |
|---|
| 30 | scripts = [] |
|---|
| 31 | for i in projects: |
|---|
| 32 | scripts.extend(dist.getScripts(i)) |
|---|
| 33 | - setup_args = dict( |
|---|
| 34 | - # metadata |
|---|
| 35 | - name="Twisted", |
|---|
| 36 | - version=copyright.version, |
|---|
| 37 | - description="An asynchronous networking framework written in Python", |
|---|
| 38 | - author="Twisted Matrix Laboratories", |
|---|
| 39 | - author_email="twisted-python@twistedmatrix.com", |
|---|
| 40 | - maintainer="Glyph Lefkowitz", |
|---|
| 41 | - maintainer_email="glyph@twistedmatrix.com", |
|---|
| 42 | - url="http://twistedmatrix.com/", |
|---|
| 43 | - license="MIT", |
|---|
| 44 | - long_description="""\ |
|---|
| 45 | - An extensible framework for Python programming, with special focus |
|---|
| 46 | - on event-based network programming and multiprotocol integration. |
|---|
| 47 | |
|---|
| 48 | - It is expected that one day the project will expanded to the point |
|---|
| 49 | - that the framework will seamlessly integrate with mail, web, DNS, |
|---|
| 50 | - netnews, IRC, RDBMSs, desktop environments, and your toaster. |
|---|
| 51 | - """, |
|---|
| 52 | + setup_args = topsetup.setup_args.copy() |
|---|
| 53 | + setup_args['packages'] = dist.getPackages('twisted') |
|---|
| 54 | + setup_args['ext_modules'] = topsetup.extensions |
|---|
| 55 | + setup_args['cmdclass'] = {'build_ext': dist.build_ext_no_fail} |
|---|
| 56 | + setup_args['scripts'] = scripts |
|---|
| 57 | |
|---|
| 58 | - packages=dist.getPackages('twisted'), |
|---|
| 59 | - data_files=dist.getDataFiles('twisted'), |
|---|
| 60 | - ext_modules=topsetup.extensions, |
|---|
| 61 | - cmdclass={'build_ext': dist.build_ext_no_fail}, |
|---|
| 62 | - scripts=scripts, |
|---|
| 63 | - ) |
|---|
| 64 | if 'setuptools' in sys.modules: |
|---|
| 65 | - setup_args['install_requires'] = ['zope.interface'] |
|---|
| 66 | + setup_args['install_requires']=['zope.interface'] |
|---|
| 67 | dist.setup(**setup_args) |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | if __name__ == "__main__": |
|---|
| 71 | + """ |
|---|
| 72 | + I invoke twisted.python.dist with the appropriate metadata about the |
|---|
| 73 | + Twisted package. |
|---|
| 74 | + """ |
|---|
| 75 | try: |
|---|
| 76 | main(sys.argv[1:]) |
|---|
| 77 | except KeyboardInterrupt: |
|---|
| 78 | Index: setupdist.py |
|---|
| 79 | =================================================================== |
|---|
| 80 | --- setupdist.py (revision 21904) |
|---|
| 81 | +++ setupdist.py (working copy) |
|---|
| 82 | @@ -1,134 +0,0 @@ |
|---|
| 83 | -#!/usr/bin/env python |
|---|
| 84 | - |
|---|
| 85 | -# Copyright (c) 2001-2004 Twisted Matrix Laboratories. |
|---|
| 86 | -# See LICENSE for details. |
|---|
| 87 | - |
|---|
| 88 | -""" |
|---|
| 89 | -Distutils-launcher for Twisted projects. |
|---|
| 90 | - |
|---|
| 91 | -This is a script which emulates a distutils-style setup.py, by delegating its |
|---|
| 92 | -invocation arguments to actual distutils setup.py scripts for each Twisted |
|---|
| 93 | -subproject in turn. |
|---|
| 94 | - |
|---|
| 95 | -It locates other setup.py scripts by detecting whether it is run in a 'sumo' |
|---|
| 96 | -configuration, which is the structure of the released tarballs, or a 'non-sumo' |
|---|
| 97 | -(development) configuration, which is the structure of the SVN repository. |
|---|
| 98 | -""" |
|---|
| 99 | - |
|---|
| 100 | -import sys, os, glob |
|---|
| 101 | - |
|---|
| 102 | -sumoSubprojects = ['core', 'conch', 'lore', 'mail', 'names', |
|---|
| 103 | - 'runner', 'web', 'words', 'news'] |
|---|
| 104 | - |
|---|
| 105 | -specialPaths = {'core': 'twisted/topfiles/setup.py'} |
|---|
| 106 | - |
|---|
| 107 | - |
|---|
| 108 | -def runInDir(dir, f, *args, **kw): |
|---|
| 109 | - """ |
|---|
| 110 | - Run a function after chdiring to a directory, and chdir back to |
|---|
| 111 | - the original directory afterwards, even if the function fails. |
|---|
| 112 | - """ |
|---|
| 113 | - origdir = os.path.abspath('.') |
|---|
| 114 | - os.chdir(dir) |
|---|
| 115 | - try: |
|---|
| 116 | - return f(*args, **kw) |
|---|
| 117 | - finally: |
|---|
| 118 | - os.chdir(origdir) |
|---|
| 119 | - |
|---|
| 120 | - |
|---|
| 121 | -def getSumoProjDir(proj): |
|---|
| 122 | - """ |
|---|
| 123 | - Return the existing directory which contains the specified |
|---|
| 124 | - subproject. If no applicable directory is found, None is returned |
|---|
| 125 | - (which may be because we are not running from a Sumo tarball). If |
|---|
| 126 | - more than one appropriate directory is found, an AssertionError is |
|---|
| 127 | - raised. |
|---|
| 128 | - """ |
|---|
| 129 | - globst = 'Twisted%s-*' % proj.capitalize() |
|---|
| 130 | - gl = glob.glob(globst) |
|---|
| 131 | - assert not len(gl) > 1, 'Wrong number of %s directories found!?' % (proj,) |
|---|
| 132 | - if gl: |
|---|
| 133 | - return gl[0] |
|---|
| 134 | - |
|---|
| 135 | - |
|---|
| 136 | -def findSetupPy(project): |
|---|
| 137 | - """ |
|---|
| 138 | - Try to find a setup.py file, and quit the process if none is found. |
|---|
| 139 | - @returns: tuple of (setup.py path, sumoMode), where sumoMode is a boolean. |
|---|
| 140 | - """ |
|---|
| 141 | - tried = [] |
|---|
| 142 | - |
|---|
| 143 | - setupPy = specialPaths.get(project) |
|---|
| 144 | - tried.append(setupPy) |
|---|
| 145 | - if setupPy and os.path.exists(setupPy): |
|---|
| 146 | - return (setupPy, False) |
|---|
| 147 | - |
|---|
| 148 | - setupPy = os.path.join('twisted', project, 'topfiles', 'setup.py') |
|---|
| 149 | - tried.append(setupPy) |
|---|
| 150 | - if os.path.exists(setupPy): |
|---|
| 151 | - return (setupPy, False) |
|---|
| 152 | - |
|---|
| 153 | - projdir = getSumoProjDir(project) |
|---|
| 154 | - if projdir: |
|---|
| 155 | - setupPy = os.path.join(projdir, 'setup.py') |
|---|
| 156 | - tried.append(setupPy) |
|---|
| 157 | - if os.path.exists(setupPy): |
|---|
| 158 | - return (setupPy, True) |
|---|
| 159 | - |
|---|
| 160 | - sys.stderr.write("Error: No such project '%s'.\n" % (project,)) |
|---|
| 161 | - sys.stderr.write(" (%s not found)\n" % (tried,)) |
|---|
| 162 | - sys.exit(1) |
|---|
| 163 | - |
|---|
| 164 | -def runSetup(project, args): |
|---|
| 165 | - setupPy, sumoMode = findSetupPy(project) |
|---|
| 166 | - |
|---|
| 167 | - # Packaged setup.py files want to be run in the root directory of |
|---|
| 168 | - # their source, whereas out of SVN they should be run from the |
|---|
| 169 | - # root directory of the entire tree. |
|---|
| 170 | - if sumoMode: |
|---|
| 171 | - result = runInDir(os.path.dirname(setupPy), os.spawnv, |
|---|
| 172 | - os.P_WAIT, sys.executable, |
|---|
| 173 | - [sys.executable, 'setup.py'] + args) |
|---|
| 174 | - else: |
|---|
| 175 | - result = os.spawnv(os.P_WAIT, sys.executable, |
|---|
| 176 | - [sys.executable, setupPy] + args) |
|---|
| 177 | - |
|---|
| 178 | - if result != 0: |
|---|
| 179 | - sys.stderr.write( |
|---|
| 180 | - "Error: Subprocess exited with result %d for project %s\n" % |
|---|
| 181 | - (result, project)) |
|---|
| 182 | - sys.exit(1) |
|---|
| 183 | - |
|---|
| 184 | - |
|---|
| 185 | -def main(args): |
|---|
| 186 | - """ |
|---|
| 187 | - Delegate setup.py functionality to individual subproject setup.py scripts. |
|---|
| 188 | - |
|---|
| 189 | - If we are running from a Sumo tarball, the TwistedCore-* directory |
|---|
| 190 | - will be added to PYTHONPATH so setup.py scripts can use |
|---|
| 191 | - functionality from Twisted. |
|---|
| 192 | - """ |
|---|
| 193 | - os.environ["PYTHONPATH"] = "." + os.pathsep + os.getenv("PYTHONPATH", "") |
|---|
| 194 | - if len(args) == 0 or args[0] in ('-h', '--help'): |
|---|
| 195 | - sys.stdout.write( |
|---|
| 196 | -"""Twisted: The Framework Of Your Internet. |
|---|
| 197 | -Usage: setup.py <distutils args..> |
|---|
| 198 | -""") |
|---|
| 199 | - runSetup('core', ['-h']) |
|---|
| 200 | - sys.exit(0) |
|---|
| 201 | - |
|---|
| 202 | - # If we've got a sumo ball, we should insert the Core directory |
|---|
| 203 | - # into sys.path because setup.py files try to import |
|---|
| 204 | - # twisted.python.dist. |
|---|
| 205 | - coredir = getSumoProjDir("core") |
|---|
| 206 | - if coredir and os.path.exists(coredir): |
|---|
| 207 | - os.environ["PYTHONPATH"] += os.pathsep + os.path.abspath(coredir) |
|---|
| 208 | - |
|---|
| 209 | - for project in sumoSubprojects: |
|---|
| 210 | - runSetup(project, args) |
|---|
| 211 | - |
|---|
| 212 | -if __name__ == "__main__": |
|---|
| 213 | - try: |
|---|
| 214 | - main(sys.argv[1:]) |
|---|
| 215 | - except KeyboardInterrupt: |
|---|
| 216 | - sys.exit(1) |
|---|