Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在setup.py中使用额外的python包索引url_Python_Pip_Packaging_Setup.py_Pypi - Fatal编程技术网

在setup.py中使用额外的python包索引url

在setup.py中使用额外的python包索引url,python,pip,packaging,setup.py,pypi,Python,Pip,Packaging,Setup.py,Pypi,有没有一种方法可以在setup.py中使用额外的Python包索引(alapip——额外的索引url pypi.example.org mypackage),这样运行Python setup.py install就我所知,你不能这样做。 您需要告诉pip这一点,或者通过传递您提到的参数,或者在用户环境中设置这一点 检查my~/.pip/pip.conf: [global] download_cache = ~/.cache/pip index-url = http://user:pass@loc

有没有一种方法可以在
setup.py
中使用额外的Python包索引(ala
pip——额外的索引url pypi.example.org mypackage
),这样运行
Python setup.py install
就我所知,你不能这样做。 您需要告诉pip这一点,或者通过传递您提到的参数,或者在用户环境中设置这一点

检查my~/.pip/pip.conf:

[global]
download_cache = ~/.cache/pip
index-url = http://user:pass@localpypiserver.com:80/simple
timeout = 300

在本例中,我的本地pypiserver还代理来自pypi.python.org的所有包,因此我不需要添加第二个条目。

如果您是包维护者,并且希望在pypi之外的某个位置托管包的一个或多个依赖项,您可以在发行版的
setup.py
文件中使用
setuptools
选项。这允许您提供一个可以定位包的显式位置

例如:

from setuptools import setup

setup(
    name='somepackage',
    install_requires=[
        'somedep'
    ],
    dependency_links=[
        'https://pypi.example.org/pypi/somedep/'
    ]
    # ...
)
如果您拥有自己的索引服务器,则需要提供指向包含每个鸡蛋的实际下载链接的页面的链接,而不是列出所有软件包的页面(例如
https://pypi.example.org/pypi/somedep/
,而不是
https://pypi.example.org/

您可以在requirements.txt文件中包含
--额外的索引URL
。请参阅:

设置工具使用易于安装在发动机罩下

它依赖于setup.cfg或~/.pydistutils.cfg,如文档所示

可以使用在这些文件中的任意一个中定义包的额外路径。您可以使用索引url覆盖注册表url,但不能提供额外的索引url。以下示例受文档启发:

[easy_install]
find_links = http://mypackages.example.com/somedir/
             http://turbogears.org/download/
             http://peak.telecommunity.com/dist/
index-url = https://mypi.example.com

以下内容适用于我(开发,而不是安装):


其中
https://x.com/n/r/pypi-proxy/simple
是本地PyPI存储库。

使用Dockerfile时找到了解决方案:

RUN cd flask-mongoengine-0.9.5 && \
    /bin/echo -e [easy_install]\\nindex-url = https://pypi.tuna.tsinghua.edu.cn/simple >> setup.cfg && \
    python setup.py install
哪个
/bin/echo-e[easy\u install]\\n索引url=https://pypi.tuna.tsinghua.edu.cn/simple
将存在于文件
setup.cfg

[easy_install]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

这个答案似乎是错误的。请看答案的最后一段:我认为这是不对的。这个问题特别询问如何控制
setup.py
的功能(我们可以假设它使用
setuptools
)以及IIUC
requirements.txt
只有通过
pip
才能满足
I最终放弃setup.py并使用此方法。setuptools无法在requirements.txt中呈现
--额外的索引URL
。它唯一需要的是一个包含deps版本详细信息的字符串列表,等等。
请求>=2.19
也包括setup.py的位置会更有帮助。这如何处理
http
索引?例如,pip希望http索引使用
--可信主机
。据我所知,依赖关系链接已被弃用,请参见示例:。答案中的链接说,pip现在忽略了
依赖关系链接
,但没有说明要使用什么。有人找到替代者吗?不起作用,而且
python setup.py install--help
没有任何与
--index url
@NOZUONOHIGH相关的参数,谢谢,我更正了我的答案-接受索引url标志的是“develope”,而不是“install”。为什么不在源代码库中包括flask-mogoengin-0.9.5/setup.cfg?为什么要在docker构建时创建它?@JasonHarrison它不是创建而是附加。这样,在构建docker映像时,我们不需要添加/复制额外的修改过的
setup.cfg
文件,一个docker文件就可以了!
[easy_install]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple