企業(yè)內(nèi)網(wǎng)利用devpi搭建pypi私服

安裝devpi

概述

devpi包含三個組件:

  • devpi-server: 提供鏡像與緩存功能,在企業(yè)DMZ區(qū)部署,提高下載python package的效率
  • devpi-web: 提供web界面與查詢功能
  • devpi-client: 命令行工具, 提供包上傳等功能

devpi-server

# 若devpi-server與互聯(lián)網(wǎng)不通,可通過設置代理來安裝
# 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/

參考

最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,568評論 19 139
  • # Python 資源大全中文版 我想很多程序員應該記得 GitHub 上有一個 Awesome - XXX 系列...
    aimaile閱讀 26,835評論 6 427
  • 1.簡介: ? Nginx:engine X ,2002年,開源,商業(yè)版? http協(xié)議:web服務器(類似于ht...
    尛尛大尹閱讀 2,008評論 0 3
  • Page 1:nginx 服務器安裝及配置文件詳解 CentOS 6.2 x86_64 安裝 nginx 1.1 ...
    xiaojianxu閱讀 8,680評論 1 41
  • NAME dnsmasq - A lightweight DHCP and caching DNS server....
    ximitc閱讀 2,993評論 0 0

友情鏈接更多精彩內(nèi)容