使用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

原文地址:https://www.cnblogs.com/rongfengliang/p/10227110.html