views:

250

answers:

1

I need to call easy_install as a function to install some Python eggs from a bunch of servers. Precisely what I install and where I get it from is determined at run-time: For example which servers I use depends on the geographic location of the computer.

Since I cannot guarantee that any single server will always be available, it has been decided that my script needs to check a number of servers. Some locations have prohibitive web-filtering so I need to check a UNC path. Other locations require me to check a mix, as in this example:

myargs = ['-vv', '-m', '-a', '-f', '//filesrver/eggs http://webserver1/python_eggs  http://webserver2/python_eggs, 'myproject==trunk-99']
setuptools.command.easy_install.main( myargs )

It seems to work just fine when I do not provide a find-links option (-f) (in this case it just picks up the defaults from distutils.cfg), when I try to specify an additional find-links the option all I get is:

Traceback (most recent call last):
  File
"D:\workspace\pythonscripts_trunk\javapy_egg\Scripts\test_javapy.py",
line 20, in ?
result = pyproxy.requireEgg( eggspec , True, hosts )
File
"d:\workspace\pythonscripts_trunk\javapy_egg\src\calyon\javapy\pyproxy.py", line 141, in requireEgg
pkg_resources.require(eggname)
File "d:\python24\lib\site-packages\setuptools-0.6c9-py2.4.egg\pkg_resources.
py", line 626, in require
needed = self.resolve(parse_requirements(requirements))
File "d:\python24\lib\site-packages\setuptools-0.6c9-py2.4.egg\pkg_resources.py", line 524, in resolve
raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: myproject==trunk-99

Can somebody confirm the correct way to do this? For example do I use Windows or UNIX slashes in the arguments? What character must be used to seperate multiple URLs?

I'm using setuptools 0.6c9 on Windows32

+3  A: 

Quote:

myargs = ['-vv', '-m', '-a', '-f', '//filesrver/eggs http://webserver1/python_eggs http://webserver2/python_eggs, 'myproject==trunk-99']

setuptools.command.easy_install.main( myargs )

This first problem I see with this is that you're missing a single quote on the end of your list of servers to look in.

Also, it's generally a good idea to surround each URL with double quotes to make sure they each get interpreted as a single item.

I'm not sure what you're doing with this argument 'myproject==trunk-99', but the way you have it written above, easy_install is interpreting it as a package name (see the documentation).

You probably want to drop the myproject== as it is only looking for the project name, not a Boolean or keyword argument.

Also, I think you meant to use the -v argument instead of the non-existant -vv.

You were correct to use a space to separate your list of URLs/servers. Forward slashes will work on both Unix and Windows.

Something like this should work for you:

myargs = ['-v', '-m', '-a', '-f', '"//filesrver/eggs/" "http://webserver1/python_eggs/" "http://webserver2/python_eggs/"', 'trunk-99']
setuptools.command.easy_install.main( myargs )
tgray
Salim Fadhley