相当于in的--find-links/-f标志。pipsetup.py
我知道dependency_links存在,但这需要指向一个特定的文件,我想要类似的东西-f可以指向一个链接列表,可以根据版本和操作系统从中选择包。
我正在使用Artifactory托管大量python模块。几次,https: //pypi.python.org/pypi上的新python模块将以相同的名称上传。当有人尝试使用pip从Artifactory安装我的模块之一时,这会导致问题。默认情况下,pip首先查找公共软件包。
这是我尝试过的:
1.我尝试过相应地修改.pypirc文件,
[distutils]
索引服务器=
人为的
pi
带有两个索引服务器的适当条目,但是我相当确定pip会忽略此信息。
2.我尝试手动指定要使用的索引服务器。
我可以指定--index-url,--extra-index-url但当公共软件包的版本号高于私有软件包的版本号时,后者不能提供帮助。如果我指定前者,则找不到公共依赖项!就像我赢不了。
3.我尝试dependency_links在setup.py中指定。
...但此答案已弃用:pip忽略setup.py中的dependency_links
我如何配置pip来选择我的Artifactory存储库而不是公共存储库?
这是我的setup.py:
setup(
...
install_requires=['GEDThriftStubs'],
dependency_links=['git+ssh://user@git.server.com/ged-thrift-stubs.git#egg=GEDThriftStubs'],
...)
Run Code Online (Sandbox Code Playgroud)
然后我创建包:
python setup.py sdist
Run Code Online (Sandbox Code Playgroud)
然后我尝试安装它:
pip install file://path/package-0.0.1.tar.gz
在终端中获取此信息:
Downloading/unpacking GEDThriftStubs (from package==0.0.1)
Could not find any downloads that satisfy the requirement GEDThriftStubs (from package==0.0.1)
No distributions at all found for GEDThriftStubs (from package==0.0.1)
Run Code Online (Sandbox Code Playgroud)
在像这样的pip.log消息中:
Skipping link git+ssh://user@git.server.com/ged-thrift-stubs.git#egg=GEDThriftStubs; wrong project name (not gedthriftstubs)
Run Code Online (Sandbox Code Playgroud)
如果重要的话,我的项目中没有任何名称为"gedthriftstubs"的名称.
但这很好用:
pip install git+ssh://user@git.server.com/ged-thrift-stubs.git#egg=GEDThriftStubs
Run Code Online (Sandbox Code Playgroud) 到目前为止,我在这里看到的问题处理相反的情况,即提供指向 off-PyPI 依赖项的链接。就我而言,依赖项是在 PyPI 中发布的,但版本不符合我的要求。这是我的摘录setup.py
setup(
...
install_requires=["numpy>=1.11.0",
"scipy>=0.17.0",
"lasagne",
"Theano>=0.8.1",
"scipy>=0.17.0"],
dependency_links=["git+https://github.com/Lasagne/Lasagne.git#egg=lasagne"]
)
Run Code Online (Sandbox Code Playgroud)
我需要lasagne从链接安装,同时pip坚持安装PyPI版本。
编辑。我试过这样做
setup(
...
install_requires=["numpy>=1.11.0",
"scipy>=0.17.0",
"lasagne>=0.2.dev1",
"Theano>=0.8.1",
"scipy>=0.17.0"],
dependency_links=[
"git+https://github.com/Lasagne/Lasagne.git#egg=lasagne-0.2.dev1"]
)
Run Code Online (Sandbox Code Playgroud)
这导致 Could not find a version that satisfies the requirement lasagne>=0.2.dev1
编辑2
实际上通过此处--process-dependency-links所示的标志(感谢 Nehal J. Wani)使其工作。我怎样才能让这个标志默认工作?我不希望用户感到困惑。
我正在一个项目中,其中一个依赖项实际上是一个.whl不在pypi 上的依赖项(即,我必须直接从作者那里下载轮并直接pip安装它)。在我的setup.py文件中,有没有办法做类似的事情:
install_requires=[
'library.whl',
'matplotlib==2.2.2',
'numpy==1.14.2',
'opencv-python==3.4.0.12',
'Pillow==5.1.0',
'PyYAML==3.12',
],
Run Code Online (Sandbox Code Playgroud)
还是沿着这些路线,因为它不在pypi上(我只是将其添加library.whl到MANIFEST.in文件中?)?如果没有,是否有针对这种情况的推荐方法?理想情况下,我想在setup.py文件中解决此问题,这样我就可以轻松安装一个库pip install
我正准备与验证器一起开放的PR,因此正在修改造假者,并且希望能够测试我将拥有的新依赖项。
setup(
name='Faker',
...
install_requires=[
"python-dateutil>=2.4",
"six>=1.10",
"text-unidecode==1.2",
],
tests_require=[
"validators@https://github.com/kingbuzzman/validators/archive/0.13.0.tar.gz#egg=validators-0.13.0", # TODO: this will change # noqa
"ukpostcodeparser>=1.1.1",
...
],
...
)
Run Code Online (Sandbox Code Playgroud)
python setup.py test 拒绝安装0.13.0版本。
如果我将故障线向上移动install_requires=[..](应该不存在)
setup(
name='Faker',
...
install_requires=[
"python-dateutil>=2.4",
"six>=1.10",
"text-unidecode==1.2",
"validators@https://github.com/kingbuzzman/validators/archive/0.13.0.tar.gz#egg=validators-0.13.0", # TODO: this will change # noqa
],
tests_require=[
"ukpostcodeparser>=1.1.1",
...
],
...
)
Run Code Online (Sandbox Code Playgroud)
pip install -e .一切都很好-安装了正确的版本。python setup.py develop相同的问题。My guess is setuptools/distutils doing something weird -- pip seems to …