newbie bootstrap question

Sorry to ask, but I'm having with the first step of the buildout process, the bootstrap.py script. I get the following error:
Traceback (most recent call last):
File "bootstrap.py", line 76, in <module>
ws.find(pkg_resources.Requirement.parse('setuptools')).location
AttributeError: 'NoneType' object has no attribute 'location'
Unfortunately, I have no idea why this error is occurring. I am running on OS X Leopard and was just trying to bootstrap an empty buildout.cfg file to get things started. Tried googling the error, but nothing came up.
Any pointers?

On Jun 25, 2009, at 7:20 PM, David Kim wrote:
Sorry to ask, but I'm having with the first step of the buildout process, the bootstrap.py script. I get the following error:
Traceback (most recent call last): File "bootstrap.py", line 76, in <module> ws.find(pkg_resources.Requirement.parse('setuptools')).location AttributeError: 'NoneType' object has no attribute 'location'
Unfortunately, I have no idea why this error is occurring. I am running on OS X Leopard and was just trying to bootstrap an empty buildout.cfg file to get things started. Tried googling the error, but nothing came up.
Any pointers?
My guess is that you have setuptools installed in your python that wasn't installed as an egg. What is the output of running the following Python script:
import pkg_resources ws = pkg_resources.working_set print ws.find(pkg_resources.Requirement.parse('setuptools'))
?
The bootstrap script has a try/except that tries to import pkg_utils. If the import succeeds, it assumes that setiuptools is already installed. Try replacing the try/except with the contents of the except.
Jim
-- Jim Fulton Zope Corporation

Thanks Jim, I think you are correct. The result of the script you provided returned 'None'. Unfortunately, I commented out the "try" code...
#try:
# import pkg_resources
#except ImportError:
and left the "except" code...
ez = {}
exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
).read() in ez
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
import pkg_resources
...but got the same error.
I am running the OS X EPD distribution, which uses Enstaller (built on setuptools). Could this have something to do with it?
Many thanks for the help,
DK
On Fri, Jun 26, 2009 at 5:23 AM, Jim Fulton jim@zope.com wrote:
On Jun 25, 2009, at 7:20 PM, David Kim wrote:
Sorry to ask, but I'm having with the first step of the buildout process,
the bootstrap.py script. I get the following error:
Traceback (most recent call last): File "bootstrap.py", line 76, in <module> ws.find(pkg_resources.Requirement.parse('setuptools')).location AttributeError: 'NoneType' object has no attribute 'location'
Unfortunately, I have no idea why this error is occurring. I am running on OS X Leopard and was just trying to bootstrap an empty buildout.cfg file to get things started. Tried googling the error, but nothing came up.
Any pointers?
My guess is that you have setuptools installed in your python that wasn't installed as an egg. What is the output of running the following Python script:
import pkg_resources ws = pkg_resources.working_set print ws.find(pkg_resources.Requirement.parse('setuptools'))
?
The bootstrap script has a try/except that tries to import pkg_utils. If the import succeeds, it assumes that setiuptools is already installed. Try replacing the try/except with the contents of the except.
Jim
-- Jim Fulton Zope Corporation

David Kim wrote:
I am running the OS X EPD distribution, which uses Enstaller (built on setuptools). Could this have something to do with it?
Sorry, but yes, this is exactly the problem. EPD comes with Enstaller instead of setuptools, and thus there is no installed project called 'setuptools', so pkg_resources.require('setuptools') isn't going to find anything.
As a quick fix, you could re-write the code you have as pkg_resources.require('enstaller') and be on your way.
I think a better, and longer term, fix is for us to patch the 'require' method in Enstaller's version of pkg_resources so that it catches a request for setuptools and maps it to Enstaller. This is probably safe because you can't have both Enstaller and setuptools installed without getting errors, plus Enstaller includes a patched version of setuptools.
-- Dave

Thanks Dave, appreciate the tip.
Dave Peterson dpeterson@enthought.com wrote:
As a quick fix, you could re-write the code you have as pkg_resources.require('enstaller') and be on your way.
I tried replacing 'setuptools' with 'enstaller' in the code and got the following result:
Retrieved config from: /Users/davidkim/.enstallerrc
Retrieved config from: /Users/davidkim/.enstallerrc
There is no difference between the current state and the most recent saved
state in the enstaller.cache, so the current state does not need to be saved.
There is no difference between the current state and the most recent saved
state in the enstaller.cache, so the current state does not need to be saved.
Traceback (most recent call last):
File "bootstrap.py", line 91, in <module>
import zc.buildout.buildout
File
"/private/var/folders/A4/A44P935JH0OrA7hGlWeH7E+++TI/-Tmp-/tmpRKD30Q/zc.buildout-1.3.0-py2.5.egg/zc/buildout/buildout.py", line 35, in <module>
import zc.buildout.easy_install
File
"/private/var/folders/A4/A44P935JH0OrA7hGlWeH7E+++TI/-Tmp-/tmpRKD30Q/zc.buildout-1.3.0-py2.5.egg/zc/buildout/easy_install.py", line 64, in <module>
pkg_resources.Requirement.parse('setuptools')
AttributeError: 'NoneType' object has no attribute 'location'
It's unclear to me where these files are and how I can get to them. I used the following bootstrap.py code.
import os, shutil, sys, tempfile, urllib2
tmpeggs = tempfile.mkdtemp()
is_jython = sys.platform.startswith('java')
ez = {}
exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
).read() in ez
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
import pkg_resources
if sys.platform == 'win32':
def quote(c):
if ' ' in c:
return '"%s"' % c # work around spawn lamosity on windows
else:
return c
else:
def quote (c):
return c
cmd = 'from setuptools.command.easy_install import main; main()'
ws = pkg_resources.working_set
if len(sys.argv) > 2 and sys.argv[1] == '--version':
VERSION = '==%s' % sys.argv[2]
args = sys.argv[3:] + ['bootstrap']
else:
VERSION = ''
args = sys.argv[1:] + ['bootstrap']
if is_jython:
import subprocess
assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd',
quote(tmpeggs), 'zc.buildout' + VERSION],
env=dict(os.environ,
PYTHONPATH=
ws.find(pkg_resources.Requirement.parse('enstaller')).location
),
).wait() == 0
else:
assert os.spawnle(
os.P_WAIT, sys.executable, quote (sys.executable),
'-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout' +
VERSION,
dict(os.environ,
PYTHONPATH=
ws.find(pkg_resources.Requirement.parse('enstaller')).location
),
) == 0
ws.add_entry(tmpeggs)
ws.require('zc.buildout' + VERSION)
import zc.buildout.buildout
zc.buildout.buildout.main(args)
shutil.rmtree(tmpeggs)
Apologies in advance if I'm being dense. Thanks so much for the help.
DK
participants (3)
-
Dave Peterson
-
David Kim
-
Jim Fulton