Contenu connexe
Similaire à Python包管理工具介绍
Similaire à Python包管理工具介绍 (20)
Python包管理工具介绍
- 2. 进入python的世界
Python如何管理它的软件?
egg是python组件的基本单位,
类似java中的jar包,ruby中
的gem。
easy_install/pip 即是python的
apt-get。
$easy_install xxx
$pip install xxx
- 3. egg的结构
$ tree hello
hello
├── hello
│ └── __init__.py
├── hello.egg-info
│ ├── PKG-INFO
│ ├── SOURCES.txt
│ ├── dependency_links.txt
│ ├── entry_points.txt
│ ├── not-zip-safe
│ └── top_level.txt
├── setup.cfg
└── setup.py
- 4. 包的依赖关系
$ cat setup.py
from setuptools import setup, find_packages
setup(name='hello',
version=version,
...
keywords='',
author='',
install_requires=[
'tornado',
'mysql-python',
'cherrypy',
],
...
)
- 5. 用namespace来组织你的包
setup.py
~~~~~~~~~~~
$ tree fly.skels
setup(
... fly.skels/
namespace_packages=['fly'], ├── README.rst
├── fly
) │ ├── __init__.py
│ └── skels
│ └── __init__.py
├── fly.skels.egg-info
├── setup.cfg
└── setup.py
- 6. 使用virtualenv和pip
(sandbox) $ pip install -r requirements.txt
(sandbox) $ cat requirements.txt
simplejson
redis==2.0.0
-e svn+http://svn.myproject.org/svn/MyProject/trunk#egg=MyProject
-e git://git.myproject.org/MyProject.git#egg=MyProject
tornado
sqlalchemy
- 15. install thirdparty software
[curl]
recipe = hexagonit.recipe.cmmi
url = http://curl.haxx.se/download/curl-7.21.3.tar.bz2
md5sum = 5b57fee22090b5c43a6886fdd35af2ce
configure-options =
--disable-ldap
--disable-ldaps
--disable-rtsp
--disable-proxy
--disable-dict
environment =
PATH=${pkgconfig:location}/bin:%(PATH)s
PKG_CONFIG_PATH=${openssl:location}/lib/pkgconfig
LDFLAGS=-Wl,-rpath -Wl,${zlib:location}/lib -Wl,-rpath -Wl,${openssl:
location}/lib