上传到pypi,并用pip下载

时间:2012-04-11 14:01:19

标签: python package pip distutils pypi

我已经写了一个小工具并上传到pypi(here),但我无法使用pip下载它。这是点子日志:

------------------------------------------------------------
c:\python32\scripts\pip-script.py run on 04/11/12 15:53:45
Downloading/unpacking undo

  Getting page http://pypi.python.org/simple/undo
  Could not fetch URL http://pypi.python.org/simple/undo: HTTP Error 301: Moved Permanently - Redirection to url '/simple/undo/' is not allowed
  Will skip URL http://pypi.python.org/simple/undo when looking for download links for undo
  Getting page http://pypi.python.org/simple/
  Real name of requirement undo is undo

  URLs to search for versions for undo:
  * http://pypi.python.org/simple/undo/
  Getting page http://pypi.python.org/simple/undo/
  Getting page http://bitbucket.org/aquavitae/undo
  Analyzing links from page http://pypi.python.org/simple/undo/
    Skipping link http://bitbucket.org/aquavitae/undo (from http://pypi.python.org/simple/undo/); not a file
    Could not parse version from link: https://bitbucket.org/aquavitae/undo/get/latest.tar.gz (from http://pypi.python.org/simple/undo/)
    Skipping link https://bitbucket.org/aquavitae/undo/get/latest.tar.gz (from http://pypi.python.org/simple/undo/); wrong project name (not undo)
  Could not find any downloads that satisfy the requirement undo

No distributions at all found for undo

Exception information:
Traceback (most recent call last):
  File "C:\python32\lib\site-packages\pip\basecommand.py", line 104, in main
    status = self.run(options, args)
  File "C:\python32\lib\site-packages\pip\commands\install.py", line 245, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "C:\python32\lib\site-packages\pip\req.py", line 978, in prepare_files
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
  File "C:\python32\lib\site-packages\pip\index.py", line 157, in find_requirement
    raise DistributionNotFound('No distributions at all found for %s' % req)
pip.exceptions.DistributionNotFound: No distributions at all found for undo

任何人都可以看到我出错的地方吗?我支持代理,虽然这可能是问题,但是pip与其他软件包没有问题,只是这个,所以我假设我以某种方式将它打包错了。

5 个答案:

答案 0 :(得分:1)

https中指向bitbucket的链接仅在您通过身份验证时有效。请改用bitbucket上的http链接。

(pypi页面中的网站/问题跟踪链接同样存在问题,我无法先登录就无法访问它)

编辑:http链接重定向到登录页面,登录后,我得到了:

  

您无权访问此存储库。

答案 1 :(得分:1)

有多个问题:你的tar文件中没有包名('undo'不是'latest.tar.gz'的子串);和pypi由于某种原因想要重定向(这似乎不正常,所以我不会进入那个)。

通常pip会首先查看与您的软件包名称匹配的所有网址,包括主页和pypi在http://pypi.python.org/simple/undo/上提供的下载页面(假设您同时指定了这两个网址)。这些页面中包含项目名称的任何网址都会被分析。

有几件事让pip拒绝了一个网址:

Skipping link http://bitbucket.org/aquavitae/undo (from http://pypi.python.org/simple/undo/); not a file

此网址已撤消,但未指向文件。

Could not parse version from link: https://bitbucket.org/aquavitae/undo/get/latest.tar.gz (from http://pypi.python.org/simple/undo/)

latest.tar.gz

中没有版本号
Skipping link https://bitbucket.org/aquavitae/undo/get/latest.tar.gz (from http://pypi.python.org/simple/undo/); wrong project name (not undo)

文件组件中没有项目名称undo

现在的工作原理是因为https://bitbucket.org/aquavitae/undo/downloads是可访问的,并且在其中的文件名部分中有3个与undo相关的链接,而许多链接中没有。使用:

pip install undo --no-install --log undo.log

并查看undo.log文件。

请注意,pip使用pkg_resources中的函数parse_versions(在dist_packages中)来确定可用的最新版本。因此,即使您明确指定undo-1.1.tar.gz作为pypi下载链接上的版本,如果您的主页也指向较新版本,例如undo-1.2-dev-20120614,则后者将被视为已找到。

答案 2 :(得分:0)

您可能需要使用以latest.tar.gz#egg = undo

之类的结尾的链接

答案 3 :(得分:0)

我不知道它是一个pip或故意的错误,但是一旦我打开了bitbucket网站它工作,尽管它需要下载(并下载)的实际文件托管在pypi上。因此,如果其他人有这个问题,解决方案是确保pypi页面上的所有链接都可以访问,即使他们没有托管下载文件。

答案 4 :(得分:0)

setup.py的{​​{1}}更改为https://bitbucket.org/aquavitae/undo/get/undo-0.5.1.tar.gz