easy_install -f 与 easy_install -i 有何区别

2 投票
3 回答
2169 浏览
提问于 2025-04-15 15:09

这段内容和我之前问的这个问题有关。

我的最终目标是能够安装我的包“identity.model”以及它所有的依赖项,像这样...

$ easy_install -f http://eggs.sadphaeton.com identity.model
Searching for identity.model
Reading http://eggs.sadphaeton.com
Reading http://pypi.python.org/simple/identity.model/
Couldn't find index page for 'identity.model' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
No local packages or download links found for identity.model
error: Could not find suitable distribution for Requirement.parse('identity.model')

但不知为什么,运行这个easy_install命令时,它却跳到了我根据这些信息设置的主页。

这是我的index.html文件

<html>
 <head>
     <title>SadPhaeton Egg Repository</title>
 </head>
 <body>
    <a rel="homepage" href="AlchemyExtra">AlchemyExtra</a>
    <a rel="homepage" href="identity.model">identity.model</a>
    <a rel="homepage" href="repoze.what.plugins.config">repoze.what.plugins.config</a>

 </body>
</html>

如果我运行...

$ easy_install -i http://eggs.sadphaeton.com identity.model

它确实找到了我的包和我放在那里的repoze.what.plugins.config,因为这是一个依赖项。不过,当它去获取tw.forms(这是一个托管在pypi上的外部依赖项)时,就失败了,因为它只搜索了http://eggs.sadphaeton.com这个地址。

显然,我对“规格”理解错了。有没有人知道这里的窍门是什么?

3 个回答

0

问题在于你试图把两种不同的页面制作方式混在一起使用:-i 和 -f。你需要选择其中一种,因为 rel="" 相关的内容 能在 -i 模式下使用。

如果你想用 -f 模式,那你只需要一个包含相关文件的网页服务器目录。如果你选择 -i 模式,那么每个项目都必须有一个子目录,并且每个子目录里要有一个 index.html 文件,而这些 index.html 文件里会包含 rel="homepage" 的内容。

0

看起来关键在于在根目录的index.html文件中添加rel="download"的链接。

<html>
<head>
    <title>SadPhaeton Egg Repository</title>
</head>
<body>
    <a rel="homepage" href="AlchemyExtra">AlchemyExtra</a> <a rel="download" href="AlchemyExtra/AlchemyExtra-0.0dev-py2.6.egg">download</a><br>
    <a rel="homepage" href="identity.model">identity.model</a> <a rel="download" href="identity.model/identity.model-0.0dev-py2.6.egg">download</a><br>

    <a rel="homepage" href="repoze.what.plugins.config">repoze.what.plugins.config</a> <a rel="download" href="repoze.what.plugins.config/repoze.what.plugins.config-0.0.0-py2.6.egg">download</a><br>

</body>
</html>

这解决了我眼前的问题,不过如果规范里能有更多细节就好了。我原本以为根据我读到的内容,easy_install会去主页查找下载链接,但它似乎不想这样做。

现在我得想办法自动化这个过程,因为手动做这些事情实在太麻烦了。

3

-f 这个选项会让你提供的 URL 去查找软件包,同时也会在 PyPI 上查找。比如说,这个页面 http://dist.plone.org/release/3.3.1/ 就是一个包含分发文件的列表。

使用 -i 选项可以定义主要的索引页面。默认的索引页面是 http://pypi.python.org/simple/。可以看到,这个索引页面是软件包的索引,而不是分发文件的索引。

所以在你的情况下,easy_install -i http://eggs.sadphaeton.com identity.model 应该可以用来下载 identity.model。对我来说,这个命令在中间成功了两次,但第一次和第二次都没有成功。我不知道你是不是在尝试不同的格式?但无论如何,它会在 tw.forms 上失败,因为这个包不在你的索引页面上。

所以解决办法应该是创建一个像 http://dist.plone.org/release/3.3.1/ 这样的页面,把你的软件包放在上面。我不太确定格式需要多严格,但我觉得应该是比较灵活的。

更新:

这里有一个一步一步的解决方案:

  1. 把你所有的分发文件放在一个目录里。
  2. 进入那个目录。
  3. 输入 python -c "from SimpleHTTPServer import test; test()"
  4. 然后输入 easy_install -f http://localhost:8080/ <modulename>

这样就会安装这个模块。

撰写回答