公司內部的一些包需要私有化管理,所以內部搭建了自己的私服,一般情況會采用PyPI或者nexus 搭建,搭建成功后包需要發布到私服;
1、用戶根目錄(如:C:\Users\Administrator)下新建.pypirc文件,添加如下配置
[distutils] index-servers = nexus [nexus] repository: http://10.12.225.53:8081/nexus/repository/pypi-hosted/ username: 賬號 password: 密碼
說明:
index-servers :定義私服地址名稱,需要與倉庫節點名稱對應起來
[nexus]:定義倉庫信息
repository: 倉庫地址(倉庫的配置中獲取)
username: 登錄賬號
password: 登錄密碼
2、項目發布主要是兩步,打包、發布
i.打包
python setup.py sdist
ii.發布
- 安裝python的twine包
pip install twine
- 發布
twine upload -r [nexus] [發布文件路徑]
iii.打包並發布
python setup.py sdist upload -r [nexus]
說明:
nexus 需要與.pypirc配置的節點名稱對應起來