changeset 100:890c4fae300a

Fixes for python3.2; ez_setup.py removed - not working under python3; .hgignore updated for python3's precompiled files;
author Velko Ivanov <vivanov@ivanov-nest.com>
date Tue, 25 Oct 2011 12:12:29 +0300
parents 534a9665e3a6
children 017f53eac8bb
files .hgignore ez_setup.py flup/server/preforkserver.py setup.py
diffstat 4 files changed, 11 insertions(+), 289 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/.hgignore	Wed Nov 03 22:00:25 2010 -0700
     1.2 +++ b/.hgignore	Tue Oct 25 12:12:29 2011 +0300
     1.3 @@ -1,6 +1,6 @@
     1.4  syntax: glob
     1.5  *~
     1.6 -*.pyc
     1.7 +__pycache__
     1.8  build
     1.9  dist
    1.10  flup.egg-info
     2.1 --- a/ez_setup.py	Wed Nov 03 22:00:25 2010 -0700
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,276 +0,0 @@
     2.4 -#!python
     2.5 -"""Bootstrap setuptools installation
     2.6 -
     2.7 -If you want to use setuptools in your package's setup.py, just include this
     2.8 -file in the same directory with it, and add this to the top of your setup.py::
     2.9 -
    2.10 -    from ez_setup import use_setuptools
    2.11 -    use_setuptools()
    2.12 -
    2.13 -If you want to require a specific version of setuptools, set a download
    2.14 -mirror, or use an alternate download directory, you can do so by supplying
    2.15 -the appropriate options to ``use_setuptools()``.
    2.16 -
    2.17 -This file can also be run as a script to install or upgrade setuptools.
    2.18 -"""
    2.19 -import sys
    2.20 -DEFAULT_VERSION = "0.6c9"
    2.21 -DEFAULT_URL     = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3]
    2.22 -
    2.23 -md5_data = {
    2.24 -    'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca',
    2.25 -    'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb',
    2.26 -    'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b',
    2.27 -    'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a',
    2.28 -    'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618',
    2.29 -    'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac',
    2.30 -    'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5',
    2.31 -    'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4',
    2.32 -    'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c',
    2.33 -    'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b',
    2.34 -    'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27',
    2.35 -    'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277',
    2.36 -    'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa',
    2.37 -    'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e',
    2.38 -    'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e',
    2.39 -    'setuptools-0.6c4-py2.3.egg': 'b0b9131acab32022bfac7f44c5d7971f',
    2.40 -    'setuptools-0.6c4-py2.4.egg': '2a1f9656d4fbf3c97bf946c0a124e6e2',
    2.41 -    'setuptools-0.6c4-py2.5.egg': '8f5a052e32cdb9c72bcf4b5526f28afc',
    2.42 -    'setuptools-0.6c5-py2.3.egg': 'ee9fd80965da04f2f3e6b3576e9d8167',
    2.43 -    'setuptools-0.6c5-py2.4.egg': 'afe2adf1c01701ee841761f5bcd8aa64',
    2.44 -    'setuptools-0.6c5-py2.5.egg': 'a8d3f61494ccaa8714dfed37bccd3d5d',
    2.45 -    'setuptools-0.6c6-py2.3.egg': '35686b78116a668847237b69d549ec20',
    2.46 -    'setuptools-0.6c6-py2.4.egg': '3c56af57be3225019260a644430065ab',
    2.47 -    'setuptools-0.6c6-py2.5.egg': 'b2f8a7520709a5b34f80946de5f02f53',
    2.48 -    'setuptools-0.6c7-py2.3.egg': '209fdf9adc3a615e5115b725658e13e2',
    2.49 -    'setuptools-0.6c7-py2.4.egg': '5a8f954807d46a0fb67cf1f26c55a82e',
    2.50 -    'setuptools-0.6c7-py2.5.egg': '45d2ad28f9750e7434111fde831e8372',
    2.51 -    'setuptools-0.6c8-py2.3.egg': '50759d29b349db8cfd807ba8303f1902',
    2.52 -    'setuptools-0.6c8-py2.4.egg': 'cba38d74f7d483c06e9daa6070cce6de',
    2.53 -    'setuptools-0.6c8-py2.5.egg': '1721747ee329dc150590a58b3e1ac95b',
    2.54 -    'setuptools-0.6c9-py2.3.egg': 'a83c4020414807b496e4cfbe08507c03',
    2.55 -    'setuptools-0.6c9-py2.4.egg': '260a2be2e5388d66bdaee06abec6342a',
    2.56 -    'setuptools-0.6c9-py2.5.egg': 'fe67c3e5a17b12c0e7c541b7ea43a8e6',
    2.57 -    'setuptools-0.6c9-py2.6.egg': 'ca37b1ff16fa2ede6e19383e7b59245a',
    2.58 -}
    2.59 -
    2.60 -import sys, os
    2.61 -try: from hashlib import md5
    2.62 -except ImportError: from md5 import md5
    2.63 -
    2.64 -def _validate_md5(egg_name, data):
    2.65 -    if egg_name in md5_data:
    2.66 -        digest = md5(data).hexdigest()
    2.67 -        if digest != md5_data[egg_name]:
    2.68 -            print >>sys.stderr, (
    2.69 -                "md5 validation of %s failed!  (Possible download problem?)"
    2.70 -                % egg_name
    2.71 -            )
    2.72 -            sys.exit(2)
    2.73 -    return data
    2.74 -
    2.75 -def use_setuptools(
    2.76 -    version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
    2.77 -    download_delay=15
    2.78 -):
    2.79 -    """Automatically find/download setuptools and make it available on sys.path
    2.80 -
    2.81 -    `version` should be a valid setuptools version number that is available
    2.82 -    as an egg for download under the `download_base` URL (which should end with
    2.83 -    a '/').  `to_dir` is the directory where setuptools will be downloaded, if
    2.84 -    it is not already available.  If `download_delay` is specified, it should
    2.85 -    be the number of seconds that will be paused before initiating a download,
    2.86 -    should one be required.  If an older version of setuptools is installed,
    2.87 -    this routine will print a message to ``sys.stderr`` and raise SystemExit in
    2.88 -    an attempt to abort the calling script.
    2.89 -    """
    2.90 -    was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules
    2.91 -    def do_download():
    2.92 -        egg = download_setuptools(version, download_base, to_dir, download_delay)
    2.93 -        sys.path.insert(0, egg)
    2.94 -        import setuptools; setuptools.bootstrap_install_from = egg
    2.95 -    try:
    2.96 -        import pkg_resources
    2.97 -    except ImportError:
    2.98 -        return do_download()       
    2.99 -    try:
   2.100 -        pkg_resources.require("setuptools>="+version); return
   2.101 -    except pkg_resources.VersionConflict, e:
   2.102 -        if was_imported:
   2.103 -            print >>sys.stderr, (
   2.104 -            "The required version of setuptools (>=%s) is not available, and\n"
   2.105 -            "can't be installed while this script is running. Please install\n"
   2.106 -            " a more recent version first, using 'easy_install -U setuptools'."
   2.107 -            "\n\n(Currently using %r)"
   2.108 -            ) % (version, e.args[0])
   2.109 -            sys.exit(2)
   2.110 -        else:
   2.111 -            del pkg_resources, sys.modules['pkg_resources']    # reload ok
   2.112 -            return do_download()
   2.113 -    except pkg_resources.DistributionNotFound:
   2.114 -        return do_download()
   2.115 -
   2.116 -def download_setuptools(
   2.117 -    version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
   2.118 -    delay = 15
   2.119 -):
   2.120 -    """Download setuptools from a specified location and return its filename
   2.121 -
   2.122 -    `version` should be a valid setuptools version number that is available
   2.123 -    as an egg for download under the `download_base` URL (which should end
   2.124 -    with a '/'). `to_dir` is the directory where the egg will be downloaded.
   2.125 -    `delay` is the number of seconds to pause before an actual download attempt.
   2.126 -    """
   2.127 -    import urllib2, shutil
   2.128 -    egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3])
   2.129 -    url = download_base + egg_name
   2.130 -    saveto = os.path.join(to_dir, egg_name)
   2.131 -    src = dst = None
   2.132 -    if not os.path.exists(saveto):  # Avoid repeated downloads
   2.133 -        try:
   2.134 -            from distutils import log
   2.135 -            if delay:
   2.136 -                log.warn("""
   2.137 ----------------------------------------------------------------------------
   2.138 -This script requires setuptools version %s to run (even to display
   2.139 -help).  I will attempt to download it for you (from
   2.140 -%s), but
   2.141 -you may need to enable firewall access for this script first.
   2.142 -I will start the download in %d seconds.
   2.143 -
   2.144 -(Note: if this machine does not have network access, please obtain the file
   2.145 -
   2.146 -   %s
   2.147 -
   2.148 -and place it in this directory before rerunning this script.)
   2.149 ----------------------------------------------------------------------------""",
   2.150 -                    version, download_base, delay, url
   2.151 -                ); from time import sleep; sleep(delay)
   2.152 -            log.warn("Downloading %s", url)
   2.153 -            src = urllib2.urlopen(url)
   2.154 -            # Read/write all in one block, so we don't create a corrupt file
   2.155 -            # if the download is interrupted.
   2.156 -            data = _validate_md5(egg_name, src.read())
   2.157 -            dst = open(saveto,"wb"); dst.write(data)
   2.158 -        finally:
   2.159 -            if src: src.close()
   2.160 -            if dst: dst.close()
   2.161 -    return os.path.realpath(saveto)
   2.162 -
   2.163 -
   2.164 -
   2.165 -
   2.166 -
   2.167 -
   2.168 -
   2.169 -
   2.170 -
   2.171 -
   2.172 -
   2.173 -
   2.174 -
   2.175 -
   2.176 -
   2.177 -
   2.178 -
   2.179 -
   2.180 -
   2.181 -
   2.182 -
   2.183 -
   2.184 -
   2.185 -
   2.186 -
   2.187 -
   2.188 -
   2.189 -
   2.190 -
   2.191 -
   2.192 -
   2.193 -
   2.194 -
   2.195 -
   2.196 -
   2.197 -
   2.198 -def main(argv, version=DEFAULT_VERSION):
   2.199 -    """Install or upgrade setuptools and EasyInstall"""
   2.200 -    try:
   2.201 -        import setuptools
   2.202 -    except ImportError:
   2.203 -        egg = None
   2.204 -        try:
   2.205 -            egg = download_setuptools(version, delay=0)
   2.206 -            sys.path.insert(0,egg)
   2.207 -            from setuptools.command.easy_install import main
   2.208 -            return main(list(argv)+[egg])   # we're done here
   2.209 -        finally:
   2.210 -            if egg and os.path.exists(egg):
   2.211 -                os.unlink(egg)
   2.212 -    else:
   2.213 -        if setuptools.__version__ == '0.0.1':
   2.214 -            print >>sys.stderr, (
   2.215 -            "You have an obsolete version of setuptools installed.  Please\n"
   2.216 -            "remove it from your system entirely before rerunning this script."
   2.217 -            )
   2.218 -            sys.exit(2)
   2.219 -
   2.220 -    req = "setuptools>="+version
   2.221 -    import pkg_resources
   2.222 -    try:
   2.223 -        pkg_resources.require(req)
   2.224 -    except pkg_resources.VersionConflict:
   2.225 -        try:
   2.226 -            from setuptools.command.easy_install import main
   2.227 -        except ImportError:
   2.228 -            from easy_install import main
   2.229 -        main(list(argv)+[download_setuptools(delay=0)])
   2.230 -        sys.exit(0) # try to force an exit
   2.231 -    else:
   2.232 -        if argv:
   2.233 -            from setuptools.command.easy_install import main
   2.234 -            main(argv)
   2.235 -        else:
   2.236 -            print "Setuptools version",version,"or greater has been installed."
   2.237 -            print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'
   2.238 -
   2.239 -def update_md5(filenames):
   2.240 -    """Update our built-in md5 registry"""
   2.241 -
   2.242 -    import re
   2.243 -
   2.244 -    for name in filenames:
   2.245 -        base = os.path.basename(name)
   2.246 -        f = open(name,'rb')
   2.247 -        md5_data[base] = md5(f.read()).hexdigest()
   2.248 -        f.close()
   2.249 -
   2.250 -    data = ["    %r: %r,\n" % it for it in md5_data.items()]
   2.251 -    data.sort()
   2.252 -    repl = "".join(data)
   2.253 -
   2.254 -    import inspect
   2.255 -    srcfile = inspect.getsourcefile(sys.modules[__name__])
   2.256 -    f = open(srcfile, 'rb'); src = f.read(); f.close()
   2.257 -
   2.258 -    match = re.search("\nmd5_data = {\n([^}]+)}", src)
   2.259 -    if not match:
   2.260 -        print >>sys.stderr, "Internal error!"
   2.261 -        sys.exit(2)
   2.262 -
   2.263 -    src = src[:match.start(1)] + repl + src[match.end(1):]
   2.264 -    f = open(srcfile,'w')
   2.265 -    f.write(src)
   2.266 -    f.close()
   2.267 -
   2.268 -
   2.269 -if __name__=='__main__':
   2.270 -    if len(sys.argv)>2 and sys.argv[1]=='--md5update':
   2.271 -        update_md5(sys.argv[2:])
   2.272 -    else:
   2.273 -        main(sys.argv[1:])
   2.274 -
   2.275 -
   2.276 -
   2.277 -
   2.278 -
   2.279 -
     3.1 --- a/flup/server/preforkserver.py	Wed Nov 03 22:00:25 2010 -0700
     3.2 +++ b/flup/server/preforkserver.py	Tue Oct 25 12:12:29 2011 +0300
     3.3 @@ -136,7 +136,7 @@
     3.4              try:
     3.5                  r, w, e = select.select(r, [], [], timeout)
     3.6              except select.error as e:
     3.7 -                if e.errno != errno.EINTR:
     3.8 +                if e.args[0] != errno.EINTR:
     3.9                      raise
    3.10  
    3.11              # Scan child sockets and tend to those that need attention.
    3.12 @@ -145,7 +145,7 @@
    3.13                  try:
    3.14                      state = child.recv(1)
    3.15                  except socket.error as e:
    3.16 -                    if e.errno in (errno.EAGAIN, errno.EINTR):
    3.17 +                    if e.args[0] in (errno.EAGAIN, errno.EINTR):
    3.18                          # Guess it really didn't need attention?
    3.19                          continue
    3.20                      raise
    3.21 @@ -214,7 +214,7 @@
    3.22                  try:
    3.23                      os.kill(pid, signal.SIGINT)
    3.24                  except OSError as e:
    3.25 -                    if e.errno != errno.ESRCH:
    3.26 +                    if e.args[0] != errno.ESRCH:
    3.27                          raise
    3.28  
    3.29          def alrmHandler(signum, frame):
    3.30 @@ -230,7 +230,7 @@
    3.31              try:
    3.32                  pid, status = os.wait()
    3.33              except OSError as e:
    3.34 -                if e.errno in (errno.ECHILD, errno.EINTR):
    3.35 +                if e.args[0] in (errno.ECHILD, errno.EINTR):
    3.36                      break
    3.37              if pid in self._children:
    3.38                  del self._children[pid]
    3.39 @@ -242,7 +242,7 @@
    3.40              try:
    3.41                  os.kill(pid, signal.SIGKILL)
    3.42              except OSError as e:
    3.43 -                if e.errno != errno.ESRCH:
    3.44 +                if e.args[0] != errno.ESRCH:
    3.45                      raise
    3.46  
    3.47      def _reapChildren(self):
    3.48 @@ -251,7 +251,7 @@
    3.49              try:
    3.50                  pid, status = os.waitpid(-1, os.WNOHANG)
    3.51              except OSError as e:
    3.52 -                if e.errno == errno.ECHILD:
    3.53 +                if e.args[0] == errno.ECHILD:
    3.54                      break
    3.55                  raise
    3.56              if pid <= 0:
    3.57 @@ -275,7 +275,7 @@
    3.58          try:
    3.59              pid = os.fork()
    3.60          except OSError as e:
    3.61 -            if e.errno in (errno.EAGAIN, errno.ENOMEM):
    3.62 +            if e.args[0] in (errno.EAGAIN, errno.ENOMEM):
    3.63                  return False # Can't fork anymore.
    3.64              raise
    3.65          if not pid:
    3.66 @@ -316,9 +316,9 @@
    3.67                  parent.send(msg)
    3.68                  return True
    3.69              except socket.error as e:
    3.70 -                if e.errno == errno.EPIPE:
    3.71 +                if e.args[0] == errno.EPIPE:
    3.72                      return False # Parent is gone
    3.73 -                if e.errno == errno.EAGAIN:
    3.74 +                if e.args[0] == errno.EAGAIN:
    3.75                      # Wait for socket change before sending again
    3.76                      select.select([], [parent], [])
    3.77                  else:
    3.78 @@ -355,7 +355,7 @@
    3.79              try:
    3.80                  clientSock, addr = sock.accept()
    3.81              except socket.error as e:
    3.82 -                if e.errno == errno.EAGAIN:
    3.83 +                if e.args[0] == errno.EAGAIN:
    3.84                      # Or maybe not.
    3.85                      continue
    3.86                  raise
     4.1 --- a/setup.py	Wed Nov 03 22:00:25 2010 -0700
     4.2 +++ b/setup.py	Tue Oct 25 12:12:29 2011 +0300
     4.3 @@ -1,6 +1,4 @@
     4.4  # Bootstrap setuptools
     4.5 -from ez_setup import use_setuptools
     4.6 -use_setuptools()
     4.7  
     4.8  from setuptools import setup, find_packages
     4.9  setup(