pip安装依赖链接

Ahm*_*DAL 12 python pip setuptools

我正在使用python version 2.7pip version is 1.5.6.

我想从url安装额外的库,就像正在安装setup.py上的git repo一样.

我在install_requires参数中加入了额外内容setup.py.这意味着,我的库需要额外的库,并且还必须安装它们.

...
install_requires=[
    "Django",
    ....
],
...
Run Code Online (Sandbox Code Playgroud)

但是,像git的回购协议的URL不是有效的字符串install_requiressetup.py.假设,我想从github安装一个库.我已经搜索关于这个问题,我发现一些东西,我可以把库,使得dependency_linkssetup.py.但那仍然行不通.这是我的依赖链接定义;

dependency_links=[
    "https://github.com/.../tarball/master/#egg=1.0.0",
    "https://github.com/.../tarball/master#egg=0.9.3",
], 
Run Code Online (Sandbox Code Playgroud)

链接有效.我可以使用这些网址从互联网浏览器下载它们.我的设置仍然没有安装这些额外的库.我也尝试过--process-dependency-links参数来强制点子.但结果是一样的.我在翻录时没有错误.

安装后,我看不到pip freeze结果库dependency_links.

如何使用我的setup.py安装下载它们?

编辑:

这是我的完整 setup.py

from setuptools import setup

try:
    long_description = open('README.md').read()
except IOError:
    long_description = ''

setup(
    name='esef-sso',
    version='1.0.0.0',
    description='',
    url='https://github.com/egemsoft/esef-sso.git',
    keywords=["django", "egemsoft", "sso", "esefsso"],
    install_requires=[
        "Django",
        "webservices",
        "requests",
        "esef-auth==1.0.0.0",
        "django-simple-sso==0.9.3"
    ],
    dependency_links=[
        "https://github.com/egemsoft/esef-auth/tarball/master/#egg=1.0.0.0",
        "https://github.com/egemsoft/django-simple-sso/tarball/master#egg=0.9.3",
    ],

    packages=[
        'esef_sso_client',
        'esef_sso_client.models',
        'esef_sso_server',
        'esef_sso_server.models',
    ],
    include_package_data=True,
    zip_safe=False,
    platforms=['any'],
)
Run Code Online (Sandbox Code Playgroud)

编辑2:

这是pip日志;

Downloading/unpacking esef-auth==1.0.0.0 (from esef-sso==1.0.0.0)
  Getting page https://pypi.python.org/simple/esef-auth/
  Could not fetch URL https://pypi.python.org/simple/esef-auth/: 404 Client Error: Not Found
  Will skip URL https://pypi.python.org/simple/esef-auth/ when looking for download links for esef-auth==1.0.0.0 (from esef-sso==1.0.0.0)
  Getting page https://pypi.python.org/simple/
  URLs to search for versions for esef-auth==1.0.0.0 (from esef-sso==1.0.0.0):
  * https://pypi.python.org/simple/esef-auth/1.0.0.0
  * https://pypi.python.org/simple/esef-auth/
  Getting page https://pypi.python.org/simple/esef-auth/1.0.0.0
  Could not fetch URL https://pypi.python.org/simple/esef-auth/1.0.0.0: 404 Client Error: Not Found
  Will skip URL https://pypi.python.org/simple/esef-auth/1.0.0.0 when looking for download links for esef-auth==1.0.0.0 (from esef-sso==1.0.0.0)
  Getting page https://pypi.python.org/simple/esef-auth/
  Could not fetch URL https://pypi.python.org/simple/esef-auth/: 404 Client Error: Not Found
  Will skip URL https://pypi.python.org/simple/esef-auth/ when looking for download links for esef-auth==1.0.0.0 (from esef-sso==1.0.0.0)
  Could not find any downloads that satisfy the requirement esef-auth==1.0.0.0 (from esef-sso==1.0.0.0)
Cleaning up...
  Removing temporary dir /Users/ahmetdal/.virtualenvs/esef-sso-example/build...
No distributions at all found for esef-auth==1.0.0.0 (from esef-sso==1.0.0.0)
Exception information:
Traceback (most recent call last):
  File "/Users/ahmetdal/.virtualenvs/esef-sso-example/lib/python2.7/site-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/Users/ahmetdal/.virtualenvs/esef-sso-example/lib/python2.7/site-packages/pip/commands/install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/Users/ahmetdal/.virtualenvs/esef-sso-example/lib/python2.7/site-packages/pip/req.py", line 1177, in prepare_files
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
  File "/Users/ahmetdal/.virtualenvs/esef-sso-example/lib/python2.7/site-packages/pip/index.py", line 277, in find_requirement
    raise DistributionNotFound('No distributions at all found for %s' % req)
DistributionNotFound: No distributions at all found for esef-auth==1.0.0.0 (from esef-sso==1.0.0.0)
Run Code Online (Sandbox Code Playgroud)

看来,它没有使用的来源dependency_links.

Pyk*_*ler 18

Pip一段时间后删除了对dependency_links的支持.支持dependency_links最新版本的pip是1.3.1,以便安装它

pip install pip==1.3.1
Run Code Online (Sandbox Code Playgroud)

您的依赖关系链接应该在那时工作.请注意,dependency_links始终是pip的最后手段,即.如果pypi上存在具有相同名称的包,则会选择超过您的包.

注意,https://github.com/pypa/pip/pull/1955似乎开始允许dependency_links,pip保留它,但你可能需要使用一些命令行开关来使用更新版本的pip.

编辑:从第7点开始......他们重新考虑了dep链接并且已经启用了他们,即使他们没有删除弃用通知,也不会从他们似乎要留下的讨论中获得.使用pip> = 7,您可以在这里安装

pip install -e . --process-dependency-links --allow-all-external
Run Code Online (Sandbox Code Playgroud)

或者将以下内容添加到pip.conf中,例如 /etc/pip.conf

[install]
process-dependency-links = yes
allow-all-external = yes
trusted-host =
    bitbucket.org
    github.com
Run Code Online (Sandbox Code Playgroud)

编辑

我学到的一个技巧是将版本号提升到非常高的值,以确保pip不喜欢非依赖链接版本(如果这是你想要的东西).从上面的示例中,使依赖关系链接看起来像:

"https://github.com/egemsoft/django-simple-sso/tarball/master#egg=999.0.0",
Run Code Online (Sandbox Code Playgroud)

还要确保版本看起来像示例或是日期版本,任何其他版本控制将使pip认为它是开发版本并且不会安装它.

  • 也许您应该删除有关 pip 版本 1.3.1 的信息,它已经很旧了 (4认同)

Mih*_*otă 14

--process-dependency-links启用选项dependency_links在皮普19.0删除

相反,您可以使用PEP 508 URL来指定您的依赖关系,从Pip 18.1开始支持该依赖关系。这是摘自的示例setup.py

install_requires=[
    "numpy",
    "package1 @ git+https://github.com/user1/package1",
    "package2 @ git+https://github.com/user2/package2@branch1",
],
Run Code Online (Sandbox Code Playgroud)

请注意,Pip不支持从PyPI安装具有此类依赖性的软件包,将来您将无法将其上传到PyPI(请参阅Pip 18.1的新闻条目)


mja*_*day 8

您需要确保将依赖项包含在您的中install_requires.

这是一个例子 setup.py

#!/usr/bin/env python
from setuptools import setup

setup(
    name='foo',
    version='0.0.1',
    install_requires=[
        'balog==0.0.7'
    ],
    dependency_links=[
        'https://github.com/balanced/balog/tarball/master#egg=balog-0.0.7'
    ]
)
Run Code Online (Sandbox Code Playgroud)

以下是您的示例的问题setup.py:

您在设置的依赖关系链接中缺少鸡蛋名称.

你有

https://github.com/egemsoft/esef-auth/tarball/master/#egg=1.0.0.0

你需要

https://github.com/egemsoft/esef-auth/tarball/master/#egg=esef-auth-1.0.0.0