如何使"pip 搜索"与我的本地 pypi 服务器一起使用?



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

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

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

当库的名称已知并且您只需运行pip install fancy-lib时,这有效。但是,在搜索包时,pip 似乎忽略了索引网址:

$  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 服务器一起使用?

似乎这只是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

最新更新