
Please be gentle... Newbie to distutils, trying to install django 0.95 egg (www.djangoproject.com) from behind a corporate windows firewall. django in turn tries to download and install setuptools - which fails due to firewall. As per ez_setup.py error message, I downloaded the setuptools egg, put it in the same dir and re-ran: but got same message. Took a look at the code and found out why (expects the egg to be in the temp dir, not same dir). Strikes me it's most likely I was doing something wrong / missed an option / some other rudimentary mistake. Assuming that's the case, could someone set me straight? In the unlikely event I've found a bug I've attached a patched version below. Note the patch is anything but elegant, driven by minimal change rather than elegant solution. Very un-pythonic I know. Like I said, please be gentle... - Scoot. -- def download_setuptools( version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay = 15 ): """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. """ import urllib2, shutil egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3]) saveto = os.path.join(to_dir, egg_name) #------------------------------------------------ #Change begins #Don't download if the egg is in the current dir. #This is a horrible hack; should check for existence #in calling routine and possibly skip temp dir creation #altogether - depends on whether it's used subsequently by #setuptools. try: os.stat(egg_name) shutil.copyfile(egg_name, saveto) except: # change ends (remainder indented though) #------------------------------------------------ url = download_base + egg_name src = dst = None if not os.path.exists(saveto): # Avoid repeated downloads try: from distutils import log if delay: log.warn(""" --------------------------------------------------------------------------- This script requires setuptools version %s to run (even to display help). I will attempt to download it for you (from %s), but you may need to enable firewall access for this script first. I will start the download in %d seconds. (Note: if this machine does not have network access, please obtain the file %s and place it in this directory before rerunning this script.) ---------------------------------------------------------------------------""", version, download_base, delay, url ); from time import sleep; sleep(delay) log.warn("Downloading %s", url) src = urllib2.urlopen(url) # Read/write all in one block, so we don't create a corrupt file # if the download is interrupted. data = _validate_md5(egg_name, src.read()) dst = open(saveto,"wb"); dst.write(data) finally: if src: src.close() if dst: dst.close() return os.path.realpath(saveto)

At 08:52 PM 8/22/2006 +0100, Scott Finnie wrote:
Please be gentle...
Newbie to distutils, trying to install django 0.95 egg (www.djangoproject.com) from behind a corporate windows firewall. django in turn tries to download and install setuptools - which fails due to firewall. As per ez_setup.py error message, I downloaded the setuptools egg, put it in the same dir and re-ran: but got same message.
Were you running setup.py or ez_setup.py? Running ez_setup.py downloads to a temporary directory; running setup.py should've looked in the current directory and worked correctly.

Phillip, Thanks for reply. I used ez_setup.py per instructions here: http://peak.telecommunity.com/DevCenter/EasyInstall#installation-instruction... Looks like I should've used setup.py instead. That being the case, perhaps the text should be reworded - it currently says: "Place the egg in the same directory as ez_setup.py on the target computer before running it." Cheers, Scoot. Phillip J. Eby wrote:
At 08:52 PM 8/22/2006 +0100, Scott Finnie wrote:
Please be gentle...
Newbie to distutils, trying to install django 0.95 egg (www.djangoproject.com) from behind a corporate windows firewall. django in turn tries to download and install setuptools - which fails due to firewall. As per ez_setup.py error message, I downloaded the setuptools egg, put it in the same dir and re-ran: but got same message.
Were you running setup.py or ez_setup.py?
Running ez_setup.py downloads to a temporary directory; running setup.py should've looked in the current directory and worked correctly.

At 12:34 AM 8/23/2006 +0100, Scott Finnie wrote:
Phillip,
Thanks for reply.
I used ez_setup.py per instructions here: http://peak.telecommunity.com/DevCenter/EasyInstall#installation-instruction...
Looks like I should've used setup.py instead. That being the case, perhaps the text should be reworded - it currently says:
"Place the egg in the same directory as ez_setup.py on the target computer before running it."
Those are the instructions for installing setuptools, not Django. The error message that would've shown when you tried to install Django (following its instructions) would have said (with the appropriate blanks filled in): --------------------------------------------------------------------------- This script requires setuptools version %s to run (even to display help). I will attempt to download it for you (from %s), but you may need to enable firewall access for this script first. I will start the download in %d seconds. (Note: if this machine does not have network access, please obtain the file %s and place it in this directory before rerunning this script.) --------------------------------------------------------------------------- i.e., rerunning setup.py, which would've triggered the message in the first place. In other words, all of the documentation is correct, but the implementation is wrong. :) More specifically, everything in your case would've worked fine from following the Django instructions + error message, but a standalone setuptools installation doesn't necessarily work as advertised, so I'll look into doing something similar to your patch. Thanks for the problem report.
participants (2)
-
Phillip J. Eby
-
Scott Finnie