[Distutils] newbie bootstrap question

David Kim dkdropbox at gmail.com
Sat Jun 27 17:36:40 CEST 2009


Thanks Dave, appreciate the tip.

Dave Peterson <dpeterson at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20090627/d5c1ef2d/attachment-0001.htm>


More information about the Distutils-SIG mailing list