pip 安装依赖链接 [英] pip install dependency links
问题描述
我使用的是 python 版本 2.7
而 pip 版本是 1.5.6
.
我想从 url 安装额外的库,就像安装 setup.py 上的 git 存储库一样.
I want to install extra libraries from url like a git repo on setup.py is being installed.
我在 setup.py
的 install_requires
参数中添加了额外的内容.这意味着,我的库需要额外的库并且也必须安装.
I was putting extras in install_requires
parameter in setup.py
. This means, my library requires extra libraries and they must also be installed.
...
install_requires=[
"Django",
....
],
...
但是像 git repos 这样的 url 在 setup.py
中的 install_requires
中不是有效字符串.假设,我想从 github 安装一个库.我搜索了这个问题,我发现了一些我可以把库放在 dependency_links
中的 setup.py
.但这仍然不起作用.这是我的依赖链接定义;
But urls like git repos are not valid string in install_requires
in setup.py
. Assume that, I want to install a library from github. I have searched about that issue and I found something which I can put libraries such that in dependency_links
in setup.py
. But that still doesn't work. Here is my dependency links definition;
dependency_links=[
"https://github.com/.../tarball/master/#egg=1.0.0",
"https://github.com/.../tarball/master#egg=0.9.3",
],
链接有效.我可以使用这些网址从互联网浏览器下载它们.这些额外的库仍未随我的设置一起安装.我还尝试了 --process-dependency-links
参数来强制 pip.但结果是一样的.我在 pipping 时不会出错.
The links are valid. I can download them from a internet browser with these urls. These extra libraries are still not installed with my setting up. I also tried --process-dependency-links
parameter to force pip. But result is same. I take no error when pipping.
安装后,我在 pip freeze
结果中看到 dependency_links
中没有库.
After installation, I see no library in pip freeze
result in dependency_links
.
如何让我的 setup.py
安装可以下载它们?
How can I make them to be downloaded with my setup.py
installation?
这是我完整的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日志;
Edited 2:
Here is pip log;
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
中的源代码.
It seems, it does not use the sources in dependency_links
.
推荐答案
您需要确保在 install_requires
中也包含依赖项.
You need to make sure you include the dependency in your install_requires
too.
这是一个例子 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
的问题:
Here's the issue with your example setup.py
:
您在设置的依赖项链接中缺少鸡蛋名称.
You're missing the egg name in the dependency links you setup.
你有
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
这篇关于pip 安装依赖链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!