| 1 |
Index: twisted/python/dist.py |
|---|
| 2 |
=================================================================== |
|---|
| 3 |
--- twisted/python/dist.py (revision 22422) |
|---|
| 4 |
+++ twisted/python/dist.py (working copy) |
|---|
| 5 |
@@ -9,7 +9,7 @@ |
|---|
| 6 |
import sys, os |
|---|
| 7 |
from distutils.command import build_scripts, install_data, build_ext, build_py |
|---|
| 8 |
from distutils.errors import CompileError |
|---|
| 9 |
-from distutils import core |
|---|
| 10 |
+import setuptools |
|---|
| 11 |
|
|---|
| 12 |
twisted_subprojects = ["conch", "flow", "lore", "mail", "names", |
|---|
| 13 |
"news", "pair", "runner", "web", "web2", |
|---|
| 14 |
@@ -62,15 +62,12 @@ |
|---|
| 15 |
kw['cmdclass']['build_py'] = build_py_twisted |
|---|
| 16 |
|
|---|
| 17 |
if 'detectExtensions' in kw: |
|---|
| 18 |
- if 'ext_modules' not in kw: |
|---|
| 19 |
- kw['ext_modules'] = [True] # distutils is so lame |
|---|
| 20 |
- |
|---|
| 21 |
dE = kw['detectExtensions'] |
|---|
| 22 |
del kw['detectExtensions'] |
|---|
| 23 |
class my_build_ext(build_ext_twisted): |
|---|
| 24 |
detectExtensions = dE |
|---|
| 25 |
kw.setdefault('cmdclass', {})['build_ext'] = my_build_ext |
|---|
| 26 |
- return core.setup(**kw) |
|---|
| 27 |
+ return setuptools.setup(**kw) |
|---|
| 28 |
|
|---|
| 29 |
def getVersion(proj, base="twisted"): |
|---|
| 30 |
""" |
|---|
| 31 |
Index: twisted/__init__.py |
|---|
| 32 |
=================================================================== |
|---|
| 33 |
--- twisted/__init__.py (revision 22422) |
|---|
| 34 |
+++ twisted/__init__.py (working copy) |
|---|
| 35 |
@@ -14,14 +14,6 @@ |
|---|
| 36 |
raise RuntimeError("Twisted requires Python 2.3 or later.") |
|---|
| 37 |
del sys |
|---|
| 38 |
|
|---|
| 39 |
-# Ensure zope.interface is installed |
|---|
| 40 |
-try: |
|---|
| 41 |
- from zope.interface import Interface |
|---|
| 42 |
- del Interface |
|---|
| 43 |
-except ImportError: |
|---|
| 44 |
- raise ImportError("you need zope.interface installed " |
|---|
| 45 |
- "(http://zope.org/Products/ZopeInterface/)") |
|---|
| 46 |
- |
|---|
| 47 |
# Ensure compat gets imported |
|---|
| 48 |
from twisted.python import compat |
|---|
| 49 |
del compat |
|---|
| 50 |
Index: twisted/topfiles/setup.py |
|---|
| 51 |
=================================================================== |
|---|
| 52 |
--- twisted/topfiles/setup.py (revision 22422) |
|---|
| 53 |
+++ twisted/topfiles/setup.py (working copy) |
|---|
| 54 |
@@ -12,7 +12,6 @@ |
|---|
| 55 |
print >>sys.stderr, "You must use at least Python 2.3 for Twisted" |
|---|
| 56 |
sys.exit(3) |
|---|
| 57 |
|
|---|
| 58 |
-import distutils |
|---|
| 59 |
from distutils.core import Extension |
|---|
| 60 |
|
|---|
| 61 |
if os.path.exists('twisted'): |
|---|
| 62 |
@@ -80,6 +79,7 @@ |
|---|
| 63 |
maintainer_email="glyph@twistedmatrix.com", |
|---|
| 64 |
url="http://twistedmatrix.com/", |
|---|
| 65 |
license="MIT", |
|---|
| 66 |
+ install_requires=['zope.interface'], |
|---|
| 67 |
long_description="""\ |
|---|
| 68 |
An extensible framework for Python programming, with special focus |
|---|
| 69 |
on event-based network programming and multiprotocol integration. |
|---|
| 70 |
@@ -96,11 +96,15 @@ |
|---|
| 71 |
'twisted_trial', 'twisted_reactors'], |
|---|
| 72 |
data_files=dist.getDataFiles('twisted', ignore=dist.twisted_subprojects), |
|---|
| 73 |
detectExtensions=detectExtensions, |
|---|
| 74 |
- scripts= [ |
|---|
| 75 |
- 'bin/manhole', 'bin/mktap', 'bin/twistd', |
|---|
| 76 |
- 'bin/tap2deb', 'bin/tap2rpm', 'bin/tapconvert', |
|---|
| 77 |
- 'bin/trial', |
|---|
| 78 |
- ], |
|---|
| 79 |
+ entry_points={ 'console_scripts': [ |
|---|
| 80 |
+ 'manhole = twisted.scripts.manhole:run', |
|---|
| 81 |
+ 'mktap = twisted.scripts.mktap:run', |
|---|
| 82 |
+ 'twistd = twisted.scripts.twistd:run', |
|---|
| 83 |
+ 'tap2deb = twisted.scripts.tap2deb:run', |
|---|
| 84 |
+ 'tap2rpm = twisted.scripts.tap2rpm:run', |
|---|
| 85 |
+ 'tapconvert = twisted.scripts.tapconvert:run', |
|---|
| 86 |
+ 'trial = twisted.scripts.trial:run', |
|---|
| 87 |
+ ] } |
|---|
| 88 |
) |
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
Index: setup.py |
|---|
| 92 |
=================================================================== |
|---|
| 93 |
--- setup.py (revision 22422) |
|---|
| 94 |
+++ setup.py (working copy) |
|---|
| 95 |
@@ -1,134 +0,0 @@ |
|---|
| 96 |
-#!/usr/bin/env python |
|---|
| 97 |
- |
|---|
| 98 |
-# Copyright (c) 2001-2004 Twisted Matrix Laboratories. |
|---|
| 99 |
-# See LICENSE for details. |
|---|
| 100 |
- |
|---|
| 101 |
-""" |
|---|
| 102 |
-Distutils-launcher for Twisted projects. |
|---|
| 103 |
- |
|---|
| 104 |
-This is a script which emulates a distutils-style setup.py, by delegating its |
|---|
| 105 |
-invocation arguments to actual distutils setup.py scripts for each Twisted |
|---|
| 106 |
-subproject in turn. |
|---|
| 107 |
- |
|---|
| 108 |
-It locates other setup.py scripts by detecting whether it is run in a 'sumo' |
|---|
| 109 |
-configuration, which is the structure of the released tarballs, or a 'non-sumo' |
|---|
| 110 |
-(development) configuration, which is the structure of the SVN repository. |
|---|
| 111 |
-""" |
|---|
| 112 |
- |
|---|
| 113 |
-import sys, os, glob |
|---|
| 114 |
- |
|---|
| 115 |
-sumoSubprojects = ['core', 'conch', 'lore', 'mail', 'names', |
|---|
| 116 |
- 'runner', 'web', 'words', 'news'] |
|---|
| 117 |
- |
|---|
| 118 |
-specialPaths = {'core': 'twisted/topfiles/setup.py'} |
|---|
| 119 |
- |
|---|
| 120 |
- |
|---|
| 121 |
-def runInDir(dir, f, *args, **kw): |
|---|
| 122 |
- """ |
|---|
| 123 |
- Run a function after chdiring to a directory, and chdir back to |
|---|
| 124 |
- the original directory afterwards, even if the function fails. |
|---|
| 125 |
- """ |
|---|
| 126 |
- origdir = os.path.abspath('.') |
|---|
| 127 |
- os.chdir(dir) |
|---|
| 128 |
- try: |
|---|
| 129 |
- return f(*args, **kw) |
|---|
| 130 |
- finally: |
|---|
| 131 |
- os.chdir(origdir) |
|---|
| 132 |
- |
|---|
| 133 |
- |
|---|
| 134 |
-def getSumoProjDir(proj): |
|---|
| 135 |
- """ |
|---|
| 136 |
- Return the existing directory which contains the specified |
|---|
| 137 |
- subproject. If no applicable directory is found, None is returned |
|---|
| 138 |
- (which may be because we are not running from a Sumo tarball). If |
|---|
| 139 |
- more than one appropriate directory is found, an AssertionError is |
|---|
| 140 |
- raised. |
|---|
| 141 |
- """ |
|---|
| 142 |
- globst = 'Twisted%s-*' % proj.capitalize() |
|---|
| 143 |
- gl = glob.glob(globst) |
|---|
| 144 |
- assert not len(gl) > 1, 'Wrong number of %s directories found!?' % (proj,) |
|---|
| 145 |
- if gl: |
|---|
| 146 |
- return gl[0] |
|---|
| 147 |
- |
|---|
| 148 |
- |
|---|
| 149 |
-def findSetupPy(project): |
|---|
| 150 |
- """ |
|---|
| 151 |
- Try to find a setup.py file, and quit the process if none is found. |
|---|
| 152 |
- @returns: tuple of (setup.py path, sumoMode), where sumoMode is a boolean. |
|---|
| 153 |
- """ |
|---|
| 154 |
- tried = [] |
|---|
| 155 |
- |
|---|
| 156 |
- setupPy = specialPaths.get(project) |
|---|
| 157 |
- tried.append(setupPy) |
|---|
| 158 |
- if setupPy and os.path.exists(setupPy): |
|---|
| 159 |
- return (setupPy, False) |
|---|
| 160 |
- |
|---|
| 161 |
- setupPy = os.path.join('twisted', project, 'topfiles', 'setup.py') |
|---|
| 162 |
- tried.append(setupPy) |
|---|
| 163 |
- if os.path.exists(setupPy): |
|---|
| 164 |
- return (setupPy, False) |
|---|
| 165 |
- |
|---|
| 166 |
- projdir = getSumoProjDir(project) |
|---|
| 167 |
- if projdir: |
|---|
| 168 |
- setupPy = os.path.join(projdir, 'setup.py') |
|---|
| 169 |
- tried.append(setupPy) |
|---|
| 170 |
- if os.path.exists(setupPy): |
|---|
| 171 |
- return (setupPy, True) |
|---|
| 172 |
- |
|---|
| 173 |
- sys.stderr.write("Error: No such project '%s'.\n" % (project,)) |
|---|
| 174 |
- sys.stderr.write(" (%s not found)\n" % (tried,)) |
|---|
| 175 |
- sys.exit(1) |
|---|
| 176 |
- |
|---|
| 177 |
-def runSetup(project, args): |
|---|
| 178 |
- setupPy, sumoMode = findSetupPy(project) |
|---|
| 179 |
- |
|---|
| 180 |
- # Packaged setup.py files want to be run in the root directory of |
|---|
| 181 |
- # their source, whereas out of SVN they should be run from the |
|---|
| 182 |
- # root directory of the entire tree. |
|---|
| 183 |
- if sumoMode: |
|---|
| 184 |
- result = runInDir(os.path.dirname(setupPy), os.spawnv, |
|---|
| 185 |
- os.P_WAIT, sys.executable, |
|---|
| 186 |
- [sys.executable, 'setup.py'] + args) |
|---|
| 187 |
- else: |
|---|
| 188 |
- result = os.spawnv(os.P_WAIT, sys.executable, |
|---|
| 189 |
- [sys.executable, setupPy] + args) |
|---|
| 190 |
- |
|---|
| 191 |
- if result != 0: |
|---|
| 192 |
- sys.stderr.write( |
|---|
| 193 |
- "Error: Subprocess exited with result %d for project %s\n" % |
|---|
| 194 |
- (result, project)) |
|---|
| 195 |
- sys.exit(1) |
|---|
| 196 |
- |
|---|
| 197 |
- |
|---|
| 198 |
-def main(args): |
|---|
| 199 |
- """ |
|---|
| 200 |
- Delegate setup.py functionality to individual subproject setup.py scripts. |
|---|
| 201 |
- |
|---|
| 202 |
- If we are running from a Sumo tarball, the TwistedCore-* directory |
|---|
| 203 |
- will be added to PYTHONPATH so setup.py scripts can use |
|---|
| 204 |
- functionality from Twisted. |
|---|
| 205 |
- """ |
|---|
| 206 |
- os.environ["PYTHONPATH"] = "." + os.pathsep + os.getenv("PYTHONPATH", "") |
|---|
| 207 |
- if len(args) == 0 or args[0] in ('-h', '--help'): |
|---|
| 208 |
- sys.stdout.write( |
|---|
| 209 |
-"""Twisted: The Framework Of Your Internet. |
|---|
| 210 |
-Usage: setup.py <distutils args..> |
|---|
| 211 |
-""") |
|---|
| 212 |
- runSetup('core', ['-h']) |
|---|
| 213 |
- sys.exit(0) |
|---|
| 214 |
- |
|---|
| 215 |
- # If we've got a sumo ball, we should insert the Core directory |
|---|
| 216 |
- # into sys.path because setup.py files try to import |
|---|
| 217 |
- # twisted.python.dist. |
|---|
| 218 |
- coredir = getSumoProjDir("core") |
|---|
| 219 |
- if coredir and os.path.exists(coredir): |
|---|
| 220 |
- os.environ["PYTHONPATH"] += os.pathsep + os.path.abspath(coredir) |
|---|
| 221 |
- |
|---|
| 222 |
- for project in sumoSubprojects: |
|---|
| 223 |
- runSetup(project, args) |
|---|
| 224 |
- |
|---|
| 225 |
-if __name__ == "__main__": |
|---|
| 226 |
- try: |
|---|
| 227 |
- main(sys.argv[1:]) |
|---|
| 228 |
- except KeyboardInterrupt: |
|---|
| 229 |
- sys.exit(1) |
|---|