setuptools管理python包

setuptool管理python相关的包
一、介绍
setuptool管理python相关的包的工具。这些包是zip格式发布,但是后缀一般都是.egg
setuptool能解决python包的依赖关系
setuptool安装的包默认安装到/usr/local/lib/pythonX.X/site-packages/目录下
下载包默认到http://pypi.python.org/pypi下载
pypi为Python PackageIndex
二、安装setuptool工具
1、rhel/centos
#yum -y install python-setuptools
2、freebsd
#cd /usr/ports/devel/py-setuptools && make install clean
3、debian/ubuntu
#sudo apt-get install python-setuptools
以上使用系统包管理系统安装后需要更新一下:
# easy_install -U setuptools
4、通用方式
Download ez_setup.py , and then run:
ez_setup.py -Zf http://peak.telecommunity.com/snapshots/ RuleDispatch
#fetch http://peak.telecommunity.com/dist/ez_setup.py
#python2.7 ez_setup.py
python2.7指定版本号,以表示setuptool使用的python版本。未指定版本则使用默认,也表示默认安装的版本是最新版本。
这一约定方便,旧版本也可以继续使用
三、通过easy_install安装python包
(一)普通安装
1、安装Babel
#easy_install Babel
如果需要trac支持多语言环境,需要先安装这个库。要支持中文一定要先装。
2、安装Trac
#easy_install trac
并且附带安装了Genshi(trac所使用的网页模板库)
(二)安装本地或网络文件系统中安装egg文件
#easy_install /net/src/eggs/py2.5.egg
(三)指定包的下载路径安装
#easy_install http://trac-hacks.org/svn/iniadminplugin/0.11/
#easy_install http://trac-hacks.org/svn/accountmanagerplugin/trunk
(四)从URL源码包安装
#easy_install http://pypi.python.org/simple/asp/asp-0.1.2.4.tar.gz
条件asp-0.1.2.4.tar.gz包中的根目录中必须包括setup.py文件
(五)web上面搜索包,并自动安装
# easy_install -f http://pypi.python.org/simple/ asp
(六)指定包的版本
# easy_install asp==0.1.2.1
如果指定的版本高于现有已安装的保本就是升级了
(七)升级包
升级到最新版本(不指定版本就会升级到最新版本
# easy_install -U asp
升级到指定版本
# easy_install -U asp==0.1.2.2
四、认证和配置文件
1、有些需要认证的python站点
easy_install -f http://uid@password@pypi.python.org/simple/packages
2、使用配置文件定义下载的站点和安装的目录
配置文件位置
当前目录/setup.cfg 或当前目录/.pydistutils.cfg
配置文件内容
find-links=http://pypi.python.org/simple/ #特定搜索包的URL
allow=*.python.org #搜索的域名
install_dir=/src/lib/python #这个目录需要在PYTHONPATH中 (sys.path)
更多帮助请看easy_install --help

原文地址:https://www.cnblogs.com/diege/p/2755433.html