<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Olivier on blog &#187; Python</title>
	<atom:link href="http://ohervieu.wordpress.com/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://ohervieu.wordpress.com</link>
	<description></description>
	<lastBuildDate>Thu, 07 May 2009 13:19:45 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>fr</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='ohervieu.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/44272cd6d5ace55ae8923dc8c06305d3?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Olivier on blog &#187; Python</title>
		<link>http://ohervieu.wordpress.com</link>
	</image>
			<item>
		<title>Commande Utilisateur pour Distutils ¶</title>
		<link>http://ohervieu.wordpress.com/2008/10/13/commande-utilisateur-pour-distutils-%c2%b6/</link>
		<comments>http://ohervieu.wordpress.com/2008/10/13/commande-utilisateur-pour-distutils-%c2%b6/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 16:33:50 +0000</pubDate>
		<dc:creator>ohervieu</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Distutils]]></category>

		<guid isPermaLink="false">http://ohervieu.wordpress.com/?p=20</guid>
		<description><![CDATA[

Distutils, par défaut est relativement &#8220;trop&#8221; simple. Il ne possède, par défaut, que les commandes : build et install&#8230;
Il est cependant facile d&#8217;étendre son fonctionnement par l&#8217;enregistrement de commande supplémentaire (build_doc, test, install_doc, clean, compile_catalog &#8230;).
Ajout d&#8217;une nouvelle commande utilisateur : ¶

setup(
    ...
    ...
    cmdclass  [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ohervieu.wordpress.com&blog=4109732&post=20&subd=ohervieu&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><div class="wikipage">
<div id="searchable">
<p>Distutils, par défaut est relativement &#8220;trop&#8221; simple. Il ne possède, par défaut, que les commandes : build et install&#8230;</p>
<p>Il est cependant facile d&#8217;étendre son fonctionnement par l&#8217;enregistrement de commande supplémentaire (build_doc, test, install_doc, clean, compile_catalog &#8230;).</p>
<h2>Ajout d&#8217;une nouvelle commande utilisateur :<a class="anchor" title="Link to this section" href="https://trac.ifr.lan/sphinx/wiki/DistutilsScripting#Ajoutdunenouvellecommandeutilisateur:"> ¶</a></h2>
<div class="code">
<pre>setup(
    ...
    ...
    cmdclass  =  {<strong><span class="code-string">'test'</span></strong> : Test}
    ...
)</pre>
</div>
<p>Où test représente le nom de la cible, Test doit être une classe accessible par le script de setup.</p>
<h2>Écriture de la classe liée à la nouvelle cible :<a class="anchor" title="Link to this section" href="https://trac.ifr.lan/sphinx/wiki/DistutilsScripting#%C3%89crituredelaclasseli%C3%A9e%C3%A0lanouvellecible:"> ¶</a></h2>
<div class="code">
<pre><em><span class="code-comment"># La nouvelle classe doit hériter de la classe Command du module distutils.
</span></em><strong><span class="code-lang">from</span></strong> distutils <strong><span class="code-lang">import</span></strong> Command
<strong><span class="code-lang">class</span></strong> Test(Command):
    description = <strong><span class="code-string">'Automatically run the test suite for this module.'</span></strong>
    user_options = [] <em><span class="code-comment"># Réclamé par distutils
</span></em>
    <strong><span class="code-lang">def</span></strong> <strong><span class="code-func">initialize_options</span></strong>(self):
        <em><span class="code-comment"># Réclamé par distutils.
</span></em>        <em><span class="code-comment"># Vous pouvez opérer ici des initialisations supplémentaires.
</span></em>        <em><span class="code-comment"># Dans la plupart des cas, à laisser vide.
</span></em>        <strong><span class="code-lang">pass</span></strong>

    <strong><span class="code-lang">def</span></strong> <strong><span class="code-func">finalize_options</span></strong>(self):
        <em><span class="code-comment"># Réclamé par distutils.
</span></em>        <em><span class="code-comment"># Dans la plupart des cas, à laisser vide.
</span></em>        <strong><span class="code-lang">pass</span></strong>

    <strong><span class="code-lang">def</span></strong> <strong><span class="code-func">run</span></strong>(self)
        <em><span class="code-comment"># Lancement de votre suite de test.
</span></em>        ...
        ...</pre>
</div>
<h2>Sortie de Distutils :<a class="anchor" title="Link to this section" href="https://trac.ifr.lan/sphinx/wiki/DistutilsScripting#SortiedeDistutils:"> ¶</a></h2>
<p>Une fois ceci réalisé, si vous tapez :</p>
<div class="code">
<pre>python setup.py --help-commands</pre>
</div>
<p>Dans la section <em>Extra Commands</em> apparait la nouvelle cible test.</p>
<p>Ainsi,</p>
<div class="code">
<pre>python setup.py <strong><span class="code-lang">test</span></strong></pre>
</div>
<p>exécutera le code décrit dans la méthode run de la classe Test de votre script setup.py</p>
<p>Il est ainsi possible d&#8217;étendre à l&#8217;infini le comportement de distutils.</p></div>
</div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ohervieu.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ohervieu.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ohervieu.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ohervieu.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ohervieu.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ohervieu.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ohervieu.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ohervieu.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ohervieu.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ohervieu.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ohervieu.wordpress.com&blog=4109732&post=20&subd=ohervieu&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ohervieu.wordpress.com/2008/10/13/commande-utilisateur-pour-distutils-%c2%b6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7187b773d9a794b827d74b9e65d25b73?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ohervieu</media:title>
		</media:content>
	</item>
	</channel>
</rss>