pip安装依赖关系链接
我正在使用python version 2.7
和pip version is 1.5.6
。pip安装依赖关系链接
我想从url安装额外的库,就像正在安装setup.py的git repo。
我在setup.py
的install_requires
参数中加入临时演员。这意味着,我的图书馆需要额外的图书馆,他们也必须安装。
...
install_requires=[
"Django",
....
],
...
但网址像git的回购协议是setup.py
在install_requires
无效的字符串。假设我想从github安装一个库。我已经搜索了关于这个问题,我发现了一些我可以把图书馆,在dependency_links
在setup.py
。但这仍然行不通。这是我的依赖链接定义;
dependency_links=[
"https://github.com/.../tarball/master/#egg=1.0.0",
"https://github.com/.../tarball/master#egg=0.9.3",
],
链接有效。我可以通过这些网址从互联网浏览器下载它们。这些额外的库仍未安装我的设置。我也尝试--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'],
)
编辑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)
看来,它并不使用dependency_links
中的来源。
您需要确保您的依赖项也包含在您的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'
]
)
这里的问题,你的榜样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
皮普除去dependency_links而回的支持。latest version of pip that supports dependency_links is 1.3.1,安装它
pip install pip==1.3.1
您的依赖关系链接应该在这一点上工作。请注意,这个dependency_links总是最后的手段,即点。如果一个名称相同的软件包存在于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
或者将以下内容添加到pip.conf中,例如: /etc/pip.conf
[install]
process-dependency-links = yes
allow-all-external = yes
trusted-host =
bitbucket.org
github.com
编辑
我已经学了一招就是撞了版本号的东西实在是高,以确保PIP不喜欢非依赖性链接版本(如果那是后话你要)。从上面的例子中,使依赖链接的样子:
"https://github.com/egemsoft/django-simple-sso/tarball/master#egg=999.0.0",
还要确保版本无论是看起来像例子或者是最新版本,其他版本将PIP认为它是一个开发版本,并不会安装。
我遇到过类似的情况,我想使用shapely作为我的包依赖项之一。然而,身材匀称的人有一个警告,如果你使用Windows,你必须使用http://www.lfd.uci.edu/~gohlke/pythonlibs/的.whl文件。否则,你必须安装一个C编译器,这是我不想要的。我希望用户只需使用pip install mypackage
而不是安装一堆其他的东西。
如果你有典型的设置与dependency_links
setup(
name = 'streettraffic',
packages = find_packages(), # this must be the same as the name above
version = '0.1',
description = 'A random test lib',
author = 'Costa Huang',
author_email = '[email protected]',
install_requires=['Shapely==1.5.17'],
dependency_links = ['http://www.lfd.uci.edu/~gohlke/pythonlibs/ru4fxw3r/Shapely-1.5.17-cp36-cp36m-win_amd64.whl']
)
和运行python setup.py install
,它只是会挑身材匀称PyPI上,并导致在Windows上安装的麻烦。经过数小时的研究,我发现这个链接Force setuptools to use dependency_links to install mysqlclient和基本上使用from setuptools.command.install import install as _install
手动安装形状。
from setuptools.command.install import install as _install
from setuptools import setup, find_packages
import pip
class install(_install):
def run(self):
_install.do_egg_install(self)
# just go ahead and do it
pip.main(['install', 'http://localhost:81/Shapely-1.5.17-cp36-cp36m-win_amd64.whl'])
setup(
name = 'mypackage',
packages = find_packages(), # this must be the same as the name above
version = '0.1',
description = 'A random test lib',
author = 'Costa Huang',
author_email = '[email protected]',
cmdclass={'install': install}
)
而且该脚本很好地工作。希望能帮助到你。
它说'找不到满足要求的任何下载my-extra-libraray == 1.0.0.0(来自my-installed-library-currently == 1.0.0.0)' – 2014-09-28 17:19:10
@AhmetDAL你有两个依赖链接并安装需要指定?你可以发布你正在使用的完整的'setup.py'吗? – mjallday 2014-09-28 18:33:32
请参阅我的问题的编辑部分。 – 2014-10-01 12:57:07