<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>i&#039;m Chao-吼吼在这 &#187; Python</title>
	<atom:link href="http://www.imchao.net/tag/python/feed" rel="self" type="application/rss+xml" />
	<link>http://www.imchao.net</link>
	<description>简，是一种境界</description>
	<lastBuildDate>Fri, 03 Sep 2010 12:03:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>说说Python包管理</title>
		<link>http://www.imchao.net/linux/talk-about-python-package-management.html</link>
		<comments>http://www.imchao.net/linux/talk-about-python-package-management.html#comments</comments>
		<pubDate>Fri, 05 Feb 2010 08:29:40 +0000</pubDate>
		<dc:creator>吼吼</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[apt]]></category>
		<category><![CDATA[easy_install]]></category>
		<category><![CDATA[pypi_install]]></category>
		<category><![CDATA[setuptools]]></category>
		<category><![CDATA[stdeb]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.imchao.net/?p=273</guid>
		<description><![CDATA[虽然我的Python学习才起步，不过有时候也需要装一些额外的软件包。一般Python教程上都推荐使用easy_install。这个工具很酷，有了它，我不需要去找软件包。我可以直接easy_install 包名，它会帮我... ]]></description>
			<content:encoded><![CDATA[ <p>虽然我的Python学习才起步，不过有时候也需要装一些额外的软件包。一般Python教程上都推荐使用easy_install。这个工具很酷，有了它，我不需要去找软件包。我可以直接easy_install 包名，它会帮我去pypi查找下载最新的软件包，然后自动安装。这个和Linux上的apt、yum之类的包管理器很类似。但是问题来，作为Linux用户，我不希望我在系统上有两套包管理器。有一天我在安装Mako(一个很快的模板引擎)，我就在想我是使用apt来安装呢，还是使用easy_install来安装。于是我用apt-cache showpkg python-mako检查一下，apt源中的mako是2.4版本的。然后我又用easy_install检查了一下，是2.5版本的。当然，听说easy_install所使用的pypi库的包往往都是最新的。像我这样的更新狂肯定想装2.5版本的，那我应该使用easy_install安装吗？</p>
<p>经我研究发现，easy_install有以下问题：</p>
<p style="padding-left: 30px;">1.卸载能力低下，easy_install -m 包名，可以卸载软件包，但是卸载后还要手动删除遗留文件。</p>
<p style="padding-left: 30px;">2.可能会和apt冲突。比如某天我用easy_install安装了软件包A，后来我在用apt安装软件包B的时候依赖软件包A，而apt并不知道A的存在。<span id="more-273"></span></p>
<p>这样的工具我还敢用吗？所以我在想有没有什么东西，可以用pypi下载最新的软件包，然后自动打成deb包，再使用dpkg来安装，纳入apt的管理。在寻觅中我找到了<a href="http://pypi.python.org/pypi/stdeb/0.5.1" target="_blank">stdeb</a>这个工具很强大，提供pypi_install的指令，我只需要执行pypi_install Mako，它就会去pypi找最新的mako，然后打成deb包，再安装。很强大吧？让我们看看它还有哪些功能。</p>
<h2>stdeb</h2>
<pre class="brush: bash;">pypi-install mypackage</pre>
<p>从pypi下载最新软件包，构建deb包，再安装</p>
<pre><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px; white-space: normal; font-size: 13px;">
<pre class="brush: bash;">py2dsc mypackage-0.1.tar.gz</pre>
<p></span></pre>
<p>使用源码包构建deb src包</p>
<pre class="brush: bash;">python setup.py --command-packages=stdeb.command sdist_dsc</pre>
<p>在使用setuptools的python源码包中，构建deb src包</p>
<pre class="brush: bash;">python setup.py --command-packages=stdeb.command bdist_deb</pre>
<p>在使用setuptools的python源码包中，构建deb包</p>
<p>stdeb很强大，不过也有一些问题，比如有时候生成的deb包名与apt源中的不一样。比如我安装web.py的时候，生成的deb包是python-web-py，而apt源中的是python-webpy。这方面stdeb还有待改进那。</p>
<h2>获得stdeb</h2>
<p>如何获得stdeb呢，似乎ubuntu9.10的源中并没有stdeb。不过你可以在这里找到它<a href="http://packages.ubuntu.com/zh-cn/lucid/python-stdeb">http://packages.ubuntu.com/zh-cn/lucid/python-stdeb</a>。</p>
<p>这个版本是给10.04使用的，不过9.10也能用，先用着吧。</p>
 <p><map name='google_ad_map_273_b72cec5cd1c1c856'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/273?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_273_b72cec5cd1c1c856' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=273&amp;url= http%3A%2F%2Fwww.imchao.net%2Flinux%2Ftalk-about-python-package-management.html' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.imchao.net/linux/talk-about-python-package-management.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
