简体   繁体   English

Python pip的pip.conf和pypirc文件有什么区别?

[英]What's the difference between Python pip's pip.conf and pypirc file?

I'm having trouble reaching a nexus server that we're using to store custom python packages. 我无法访问用于存储自定义python软件包的nexus服务器。 I've been told to change the settings in both my ~/.pypirc file and the ~/.pip/pip.conf file. 有人告诉我更改~/.pypirc文件和~/.pip/pip.conf文件中的设置。

What's the difference between those two files in how they're used? 这两个文件在使用方式上有什么区别? It seems like the pip install -r requirements.txt command refers to the pip.conf file, and then the fields within the pip.conf file requires looking up the pypirc file? 这似乎是pip install -r requirements.txt命令指pip.conf文件,然后将内场pip.conf文件需要仰视pypirc文件?

Example pip.conf file: 示例pip.conf文件:

[global]
index = https://user:password@someurl.com/somerepo/pypi-group/pypi
index-url = index = https://user:password@someurl.com/somerepo/pypi-group/simple

Example pypirc file: pypirc文件示例:

[distutils]
index-servers =
    pypi
    nexus

[pypi]
repository: https://pypi.org/pypi
username: abc
password: def

[nexus]
repository: https://someurl.com/somerepo/pypi-internal
username: someuser
password: somepassword

Also, what's the difference between index and index-url in the pip.conf file? 另外,pip.conf文件中的index和index-url有什么区别?

.pypirc is a file standard used by multiple tools, but not by pip . .pypirc是多个工具( 而非pip使用的文件标准。 For example, the easy_install tool reads that file , as does twine . 例如, easy_install工具和twine一样读取该文件 It contains configuration on how to access specific PyPI index servers when publishing a package . 它包含有关发布包时如何访问特定PyPI索引服务器的配置。

pip.conf on the other hand is only used by the pip tool, and pip never publishes packages, it downloads packages from them. 另一方面, pip.conf pip工具使用,并且pip从不发布软件包,而是从中下载软件包。 As such, it never looks at the .pypirc file. 因此,它永远不会查看.pypirc文件。

If you are not publishing packages, you don't need a .pypirc file. 如果您不发布软件包,则不需要.pypirc文件。 You can't use it to configure index servers for pip . 您不能使用它为pip配置索引服务器。

As for the --index-url and --index switches, these are used for different pip commands. 至于--index-url--index开关,它们用于不同的pip命令。

  • --index-url is a common switch among several pip commands that deal with installing packages ( pip install , pip download , pip list , and pip wheel ), where it is part of a group of switches (together with --extra-index-url , --no-index , --find-links and --process-dependency-links and a few deprecated switches) that all together configure how package discovery works. --index-url是处理安装软件包的多个pip命令( pip installpip downloadpip listpip wheel )中的常用开关,它是一组开关的一部分(与--extra-index-url一起) --extra-index-url--no-index --find-links --no-index ,-- --find-links--process-dependency-links以及一些已弃用的开关)一起配置了程序包发现的工作方式。 The URL must point to a PEP 503 Simple Repository API location, the default is https://pypi.org/simple . 该URL必须指向PEP 503简单存储库API位置,默认值为https://pypi.org/simple

  • --index is only used by pip search ; --index仅用于pip search it only needs this one piece of information. 它只需要这一条信息。 It is named separately because it should point to the public search web interface, not the simple repository! 之所以单独命名,是因为它应该指向公共搜索Web界面,而不是简单的存储库! For https://pypi.org , that's https://pypi.org/pypi . 对于https://pypi.org ,即为https://pypi.org/pypi

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM