使用私有pypi仓库

1. 搭建私有源

  1. 在nexus中新加一个pypi(hosted) 类型的仓库
  2. 仓库名称为pypi-releases
  3. Deployment policy 设置为 Allow redeploy

新仓库的访问地址为:http://localhost:8081/repository/pypi-releases/
账号为nexus的登陆账号。

2. 创建.pypirc

创建文件~/.pypirc 内容:

[distutils]
index-servers = pypi-releases

[pypi-releases]
repository: http://localhost:8081/repository/pypi-releases/
username: admin
password: admin

3. 发布项目到私有仓库

# 发布tar包到仓库
python setup.py sdist upload -r pypi-releases

# 发布wheel包到仓库(推荐)
python setup.py bdist_wheel upload -r pypi-releases

# 清除build目录
python setup.py clean --all

4. 优先级问题

  • nexus中可以配置优先级,group中的顺序就是优先级
  • whl 的优先级高于tar包的优先级
  • 私有源的优先级应该比代理源的优先级高
原文地址:https://www.cnblogs.com/oaks/p/14179348.html