1. 程式人生 > >使用nexus 管理pip 私有包

使用nexus 管理pip 私有包

nexus 已經支援了對於python pip 包的管理(支援group,host,proxy)
這個是一個簡單的使用docker 執行的demo,同時集成了s3 儲存,以及
一個為了測試簡單的自定義pip 包

環境準備

  • docker-compose 檔案
 
version: "3"
services:
  nexus:
    image: sonatype/nexus3
    ports:
    - "8081:8081"
    volumes:
    - ./nexus-data:/nexus-data
  s3:
    image: minio/minio
    command: server /export
    ports:
    - "9000:9000"
    volumes:
      - ./data:/data
      - ./config:/root/.minio
    environment:
    - "MINIO_ACCESS_KEY=dalongapp"
    - "MINIO_SECRET_KEY=dalongapp"
   
  • 啟動&&測試
docker-compose up -d
 

效果

pip 包操作

upload

  • 命令
 
twine upload --repository-url http://localhost:8081/repository/mypip/ dist/*
Enter your username: admin
Enter your password:
Uploading distributions to http://localhost:8081/repository/mypip/
Uploading dalongrong_example_pkg-0.0.1-py3-none-any.whl
100%|████████████████████████████████████████████████████████████████████████████████████████| 5.60k/5.60k [00:00<00:00, 12.0kB/s]
Uploading dalongrong_example_pkg-0.0.1.tar.gz
100%|████████████████████████████████████████████████████████████████████████████████████████| 4.28k/4.28k [00:00<00:00, 16.4kB/s]
   
  • 效果

使用上傳的包

  • 新增group pip
  • 安裝pip 包
pip install -i http://localhost:8081/repository/allpip/simple/ dalongrong_example_pkg
Looking in indexes: http://localhost:8081/repository/allpip/simple/
Collecting dalongrong_example_pkg
Installing collected packages: dalongrong-example-pkg
Successfully installed dalongrong-example-pkg-0.0.1
 

說明

使用compose 自帶的dns 會有問題,新增minio s3 endpoint 的時候使用ip 地址

參考資料

https://www.cnblogs.com/rongfengliang/p/9094503.html 
https://www.cnblogs.com/rongfengliang/p/10219292.html 
https://github.com/rongfengliang/pip-demo-package 
https://github.com/rongfengliang/nexus-minio-docker-compose