Reload Original PagePrint PageEmail Page

制作本地pypi源 - To The Moon

Date Tags python

本文参考自陈沙克老师的博文CentOS6.4 PYPI本地源制作

由于公司跨机房网络有限制,且各地跳板及运维调试机都没有公网,想装python,及相关工具很麻烦,所以需要建个pypi源,解决一下这个问题

各种包

yum groupinstall "Development tools"
yum install zlib-devel bzip2-devel openssl-devel \
ncurses-devel sqlite-devel readline-devel tk-devel

Python2.7.5

当前Python的2.7的最新版本是2.7.5

cd /opt
wget http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz
tar zxvf Python-2.7.5.tgz
cd Python-2.7.5
./configure --prefix=/usr/local
make && make altinstall

distribute

https://pypi.python.org/pypi/distribute

cd /tmp
wget https://pypi.python.org/packages/source/d/distribute/distribute-0.7.3.zip --no-check-certificate
unzip distribute-0.7.3.zip
cd distribute-0.7.3
python2.7 setup.py install

virtualenv

easy_install-2.7 virtualenv

Bandersnatch

https://pypi.python.org/pypi/bandersnatch/1.0.5
安装之前,先把pip源换成国内的,目前我是用的时中国科技大学的mirror

cat ~/.pip/pip.conf
[global]
index-url = http://e.pypi.python.org/simple

安装过程,参考官方文档如下

cd /opt
virtualenv-2.7 bandersnatch
cd bandersnatch
bin/pip install -r https://bitbucket.org/ctheune/bandersnatch/raw/stable/   requirements.txt

有可能运行出现中断和各种错误,多重复运行几次就ok.(修改为国内mirror会舒服很多)

设置bandersnatch

cd /opt/bandersnatch
bin/bandersnatch mirror

会出现一个提示

2013-07-30 12:56:45,925 WARNING: Config file '/etc/bandersnatch.conf' missing,creating default config.
2013-07-30 12:56:45,926 WARNING: Please review the config file, then run 'bandersnatch' again.

编辑 /etc/bandersnatch.conf 文件就可以。默认应该就可以.
我在这里做了两个修改,一是源文件存储位置改为公司内网源的存储目录/repo,二是修改抓取的master为中科大的mirror

[mirror]
directory = /repo/pypi
master = http://e.pypi.python.org

设置Apache

我只需要把 /home/pypi/web 目录链接到apache目录下显示就可以

ln -s /repo/pypi/web /var/www/html/pypi 设置客户端 假设你的Pypi目录是 http://10.64.5.100/pypi

在用户主目录下,

mkdir $HOME/.pip
vi $HOME/.pip/pip.conf

输入下面内容

[global]
index-url = http://10.64.5.100/pypi/simple

::...

免责声明:
当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
内容版权归原作者所有;
本人对内容的有效性/合法性不承担任何强制性责任.
若有不妥, 欢迎评注提醒:

或是邮件反馈可也:
askdama[AT]googlegroups.com


订阅 substack 体验古早写作:


点击注册~> 获得 100$ 体验券: DigitalOcean Referral Badge

关注公众号, 持续获得相关各种嗯哼:
zoomquiet


自怼圈/年度番新

DU22.4
关于 ~ DebugUself with DAMA ;-)
粤ICP备18025058号-1
公安备案号: 44049002000656 ...::