制作本地pypi源

本地PYPI源制作


本文参考自陈沙克老师的博文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 /optwget http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgztar zxvf Python-2.7.5.tgzcd Python-2.7.5./configure --prefix=/usr/localmake && make altinstall

distribute

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

cd /tmpwget https://pypi.python.org/packages/source/d/distribute/distribute-0.7.3.zip --no-check-certificateunzip distribute-0.7.3.zipcd distribute-0.7.3python2.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 /optvirtualenv-2.7 bandersnatchcd bandersnatchbin/pip install -r https://bitbucket.org/ctheune/bandersnatch/raw/stable/   requirements.txt

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

设置bandersnatch

cd /opt/bandersnatchbin/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/pypimaster = 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/.pipvi $HOME/.pip/pip.conf

输入下面内容

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

参考文档 CentOS6.4 PYPI本地源制作

制作本地pypi源

相关文章:

你感兴趣的文章:

标签云: