企业内网利用devpi搭建pypi私服

安装devpi

概述

devpi包含三个组件:

  • devpi-server: 提供镜像与缓存功能,在企业DMZ区部署,提高下载python package的效率
  • devpi-web: 提供web界面与查询功能
  • devpi-client: 命令行工具, 提供包上传等功能

devpi-server

# 若devpi-server与互联网不通,可通过设置代理来安装
# pip --proxy http://proxy_server:3128 install -q -U devpi-server

pip install -q -U devpi-server
devpi-server --version

初始化与初次启动

devpi-server --init
devpi-server --start

测试

pip install -i http://localhost:3141/root/pypi/ simplejson
pip uninstall -y simplejson
easy_install -i http://localhost:3141/root/pypi/+simple/ simplejson
pip uninstall -y simplejson

devpi-web

pip install -q -U devpi-web
devpi-server --stop
devpi-server --recreate-search-index
devpi-server --start
pip search --index http://localhost:3141/root/pypi/ devpi-client

常用命令

devpi-server --init
devpi-server --start
devpi-server --stop
devpi-server --status
devpi-server --log

devpi behind proxy

export http_proxy="http://proxy_server:3128"
export https_proxy="http://proxy_server:3128"
export no_proxy="localhost,10.0.0.0/8,172.16.0.0/12"
devpi-server --start

nginx reverse proxy

# http block
upstream pypi.example.com {
    server 127.0.0.1:3141;
    keepalive 16;
}

# server block
location ~ /(root|\+search) {
        proxy_pass http://pypi.example.com;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

客户端设置

pip

# Linux:       $HOME/.pip/pip.conf
# Windows 7:   C:\ProgramData\pip\pip.ini
# windows xp:  C:\Documents and Settings\All Users\Application Data\pip\pip.ini
# or use environment variable PIP_CONFIG_FILE to specify location

# please replace example.com to your REAL domain name

[global]
index-url = http://pypi.example.com/root/pypi/+simple/

[install]
trusted-host=pypi.example.com

[search]
index = http://pypi.example.com/root/pypi/

easy_install

# $HOME/.pydistutils.cfg:
[easy_install]
index_url = http://pypi.example.com/root/pypi/+simple/

参考

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,859评论 18 139
  • # Python 资源大全中文版 我想很多程序员应该记得 GitHub 上有一个 Awesome - XXX 系列...
    aimaile阅读 26,553评论 6 427
  • 1.简介:  Nginx:engine X ,2002年,开源,商业版 http协议:web服务器(类似于ht...
    尛尛大尹阅读 1,893评论 0 3
  • Page 1:nginx 服务器安装及配置文件详解 CentOS 6.2 x86_64 安装 nginx 1.1 ...
    xiaojianxu阅读 8,568评论 1 41
  • NAME dnsmasq - A lightweight DHCP and caching DNS server....
    ximitc阅读 2,906评论 0 0