如何让'pip search`与我的本地pypi服务器一起工作?

时间:2017-08-15 11:17:44

标签: python python-3.x pip pypi pypiserver

我有一堆与互联网隔离的机器,只能访问本地网络上的某些服务。

我希望使用这些机器的用户能够从本地pypi服务器搜索并安装他们想要的任何python库。因此,我在/ etc /下创建了一个全局pip.conf,其中包含以下行:

[global]
trusted-host = my.pypi-server.com
index-url = https://my.pypi-server.com/

当知道库的名称并且您只运行pip install fancy-lib时,此方法有效。但是,在搜索包时,pip似乎忽略了index-url:

$  pip search fancy-lib -vvvv
Starting new HTTPS connection (1): pypi.python.org

$  pip install fancy-lib -vvvv
Collecting fancy-lib
  1 location(s) to search for versions of fancy-lib:
  * https://my.pypi-server.com/simple/fancy-lib
  Getting page https://my.pypi-server.com/simple/fancy-lib
  Looking up "https://my.pypi-server.com/simple/fancy-lib" in the cache
  No cache entry available
  Starting new HTTPS connection (1): https://my.pypi-server.com/

如何让pip search与我的本地pypi服务器配合使用?

1 个答案:

答案 0 :(得分:2)

这似乎只是RTM的问题。搜索索引独立于安装索引,并使用index

指定
[global]
trusted-host = my.pypi-server.com
index = https://my.pypi-server.com/
index-url = https://my.pypi-server.com/

此配置文件的替代方法是:

[global]
trusted-host = my.pypi-server.com

[search]
index = https://my.pypi-server.com/

[install]
index-url = https://my.pypi-server.com/

这不是很直观,并且已经有一个增强请求可以解决它:https://github.com/pypa/pip/issues/4263