def download_setuptools(<EOL>version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,<EOL>delay = <NUM_LIT:15><EOL>):
import urllib.request, urllib.error, urllib.parse, shutil<EOL>egg_name = "<STR_LIT>" % (version,sys.version[:<NUM_LIT:3>])<EOL>url = download_base + egg_name<EOL>saveto = os.path.join(to_dir, egg_name)<EOL>src = dst = None<EOL>if not os.path.exists(saveto):  <EOL><INDENT>try:<EOL><INDENT>from distutils import log<EOL>if delay:<EOL><INDENT>log.warn("""<STR_LIT>""",<EOL>version, download_base, delay, url<EOL>); from time import sleep; sleep(delay)<EOL><DEDENT>log.warn("<STR_LIT>", url)<EOL>src = urllib.request.urlopen(url)<EOL>data = _validate_md5(egg_name, src.read())<EOL>dst = open(saveto,"<STR_LIT:wb>"); dst.write(data)<EOL><DEDENT>finally:<EOL><INDENT>if src: src.close()<EOL>if dst: dst.close()<EOL><DEDENT><DEDENT>return os.path.realpath(saveto)<EOL>
Download setuptools from a specified location and return its filename

    `version` should be a valid setuptools version number that is available
    as an egg for download under the `download_base` URL (which should end
    with a '/'). `to_dir` is the directory where the egg will be downloaded.
    `delay` is the number of seconds to pause before an actual download attempt.