简体   繁体   English

当被称为 function 时,将额外的查找链接添加到 easy_install 的正确方法是什么?

[英]What's the correct way to add extra find-links to easy_install when called as a function?

I need to call easy_install as a function to install some Python eggs from a bunch of servers.我需要调用 easy_install 作为 function 从一堆服务器安装一些 Python 鸡蛋。 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.有些地方有禁止的网络过滤,所以我需要检查一个 UNC 路径。 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:当我不提供 find-links 选项 (-f) 时,它似乎工作得很好(在这种情况下,它只是从 distutils.cfg 中获取默认值),当我尝试指定一个额外的 find-links 选项时我全部得到的是:

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?例如,我是否在 arguments 中使用 Windows 或 UNIX 斜线? What character must be used to seperate multiple URLs?必须使用什么字符来分隔多个 URL?

I'm using setuptools 0.6c9 on Windows32我在 Windows32 上使用 setuptools 0.6c9

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.此外,通常最好用双引号将每个 URL 括起来,以确保它们都被解释为单个项目。

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 ).我不确定你在用这个参数'myproject==trunk-99'做什么,但是你上面写的方式,easy_install 将它解释为 package 名称( 参见文档)。

You probably want to drop the myproject== as it is only looking for the project name, not a Boolean or keyword argument.您可能想要删除myproject==因为它只是在寻找项目名称,而不是 Boolean 或关键字参数。

Also, I think you meant to use the -v argument instead of the non-existant -vv .另外,我认为您的意思是使用-v参数而不是不存在的-vv

You were correct to use a space to separate your list of URLs/servers.您使用空格分隔 URL/服务器列表是正确的。 Forward slashes will work on both Unix and Windows.正斜杠适用于 Unix 和 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 )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM