~certify-web-dev/twisted/certify-staging

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
  PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
  'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  <head>
<title>Twisted Documentation: Working from Twisted's Subversion repository</title>
<link href="../../howto/stylesheet.css" rel="stylesheet" type="text/css"/>
  </head>

  <body bgcolor="white">
    <h1 class="title">Working from Twisted's Subversion repository</h1>
    <div class="toc"><ol><li><a href="#auto0">Checkout</a></li><li><a href="#auto1">Alternate tree names</a></li><li><a href="#auto2">Combinator</a></li><li><a href="#auto3">Compiling C extensions</a></li><li><a href="#auto4">Running tests</a></li><li><a href="#auto5">Building docs</a></li><li><a href="#auto6">Emacs</a></li><li><a href="#auto7">Building Debian packages</a></li></ol></div>
    <div class="content">
<span/>

<p>If you're going to be doing development on Twisted itself, or if you want
to take advantage of bleeding-edge features (or bug fixes) that are not yet
available in a numbered release, you'll probably want to check out a tree from
the Twisted Subversion repository. The Trunk is where all current development
takes place.</p>

<p>This document lists some useful tips for working on this cutting
edge.</p>

<h2>Checkout<a name="auto0"/></h2>

<p>Subversion tutorials can be found elsewhere, see in particular <a href="http://subversion.tigris.org/" shape="rect">the Subversion homepage</a>. The relevant
data you need to check out a copy of the Twisted tree is available on the <a href="http://twistedmatrix.com/trac/wiki/TwistedDevelopment" shape="rect">development page
</a>, and is as follows:</p>

<pre class="shell" xml:space="preserve">
$ svn co svn://svn.twistedmatrix.com/svn/Twisted/trunk Twisted
</pre>

<h2>Alternate tree names<a name="auto1"/></h2>

<p>By using <code>svn co svn://svn.twistedmatrix.com/svn/Twisted/trunk
otherdir</code>, you can put the workspace tree in a directory other than
<q>Twisted</q>. I do this (with a name like <q>Twisted-Subversion</q>) to
remind myself that this tree comes from Subversion and not from a released
version (like <q>Twisted-1.0.5</q>). This practice can cause a few problems,
because there are a few places in the Twisted tree that need to know where
the tree starts, so they can add it to <code>sys.path</code> without
requiring the user manually set their PYTHONPATH. These functions walk the
current directory up to the root, looking for a directory named
<q>Twisted</q> (sometimes exactly that, sometimes with a
<code>.startswith</code> test). Generally these are test scripts or other
administrative tools which expect to be launched from somewhere inside the
tree (but not necessarily from the top).</p>

<p>If you rename the tree to something other than <code>Twisted</code>, these
tools may wind up trying to use Twisted source files from /usr/lib/python2.5
or elsewhere on the default <code>sys.path</code>.  Normally this won't
matter, but it is good to be aware of the issue in case you run into
problems.</p>

<p><code>twisted/test/process_twisted.py</code> is one of these programs.</p>

<h2>Combinator<a name="auto2"/></h2>

<p>In order to simplify the use of Subversion, we typically use
<a href="http://divmod.org/trac/wiki/DivmodCombinator" shape="rect">Divmod Combinator</a>.
You may find it to be useful, too.  In particular, because Twisted uses
branches for almost all feature development, if you plan to contribute to
Twisted you will probably find Combinator very useful.  For more details,
see the Combinator website, as well as the
<a href="http://divmod.org/trac/wiki/UltimateQualityDevelopmentSystem" shape="rect">
UQDS</a> page.</p>

<h2>Compiling C extensions<a name="auto3"/></h2>

<p>
There are currently several C extension modules in Twisted:
twisted.protocols._c_urlarg, twisted.internet.cfsupport,
twisted.internet.iocpreactor._iocp, and twisted.python._epoll.  These modules
are optional, but you'll have to compile them if you want to experience their
features, performance improvements, or bugs. There are two approaches.
</p>

<p>The first is to do a regular distutils <code>./setup.py build</code>, which
will create a directory under <code>build/</code> to hold both the generated
<code>.so</code> files as well as a copy of the 600-odd <code>.py</code> files
that make up Twisted. If you do this, you will need to set your PYTHONPATH to
something like <code>MyDir/Twisted/build/lib.linux-i686-2.5</code> in order to
run code against the Subversion twisted (as opposed to whatever's installed in
<code>/usr/lib/python2.5</code> or wherever python usually looks). In
addition, you will need to re-run the <code>build</code> command <em>every
time</em> you change a <code>.py</code> file. The <code>build/lib.foo</code>
directory is a copy of the main tree, and that copy is only updated when you
re-run <code>setup.py build</code>. It is easy to forget this and then wonder
why your code changes aren't being expressed.</p>

<p>The second technique is to build the C modules in place, and point your
PYTHONPATH at the top of the tree, like <code>MyDir/Twisted</code>. This way
you're using the .py files in place too, removing the confusion a forgotten
rebuild could cause with the separate build/ directory above. To build the C
modules in place, do <code>./setup.py build_ext -i</code>. You only need to
re-run this command when you change the C files. Note that
<code>setup.py</code> is not Make, it does not always get the dependencies
right (<code>.h</code> files in particular), so if you are hacking on the
cReactor you may need to manually delete the <code>.o</code> files before
doing a rebuild. Also note that doing a <code>setup.py clean</code> will
remove the <code>.o</code> files but not the final <code>.so</code> files,
they must be deleted by hand.</p>


<h2>Running tests<a name="auto4"/></h2>

<p>To run the full unit-test suite, do:</p>

<pre class="shell" xml:space="preserve">./bin/trial twisted</pre>

<p>To run a single test file (like <code>twisted/test/test_defer.py</code>),
do one of:</p>

<pre class="shell" xml:space="preserve">./bin/trial twisted.test.test_defer</pre>

<p>or</p>

<pre class="shell" xml:space="preserve">./bin/trial twisted/test/test_defer.py</pre>

<p>To run any tests that are related to a code file, like
<code>twisted/protocols/imap4.py</code>, do:</p>

<pre class="shell" xml:space="preserve">./bin/trial --testmodule twisted/mail/imap4.py</pre>

<p>This depends upon the <code>.py</code> file having an appropriate
<q>test-case-name</q> tag that indicates which test cases provide coverage.
See the <a href="test-standard.html" shape="rect">Test Standards</a> document for
details about using <q>test-case-name</q>. In this example, the
<code>twisted.mail.test.test_imap</code> test will be run.</p>

<p>Many tests create temporary files in /tmp or ./_trial_temp, but
everything in /tmp should be deleted when the test finishes. Sometimes these
cleanup calls are commented out by mistake, so if you see a stray
/tmp/@12345.1 directory, it is probably from test_dirdbm or test_popsicle.
Look for an <code>rmtree</code> that has been commented out and complain to
the last developer who touched that file.</p>

<h2>Building docs<a name="auto5"/></h2>

<p>Twisted documentation (not including the automatically-generated API docs)
is in <a href="http://twistedmatrix.com/trac/wiki/TwistedLore" shape="rect">Lore Format</a>.
These <code>.xhtml</code> files are translated into <code>.html</code> files by
the <q>bin/lore/lore</q> script, which can check the files for syntax problems
(hlint), process multiple files at once, insert the files into a template
before processing, and can also translate the files into LaTeX or PostScript
instead.</p>

<p>To build the HTML form of the howto/ docs, do the following. Note that
the index file will be placed in <code>doc/howto/index.html</code>.</p>

<pre class="shell" xml:space="preserve">
./bin/lore/lore -p --config template=doc/howto/template.tpl doc/howto/*.xhtml
</pre>

<p>To run hlint over a single Lore document, such as
<code>doc/development/policy/svn-dev.xhtml</code>, do the following. This is
useful because the HTML conversion may bail without a useful explanation if
it sees mismatched tags.</p>

<pre class="shell" xml:space="preserve">
./bin/lore/lore -n --output lint doc/development/policy/svn-dev.xhtml
</pre>

<p>To convert it to HTML (including markup, interpolation of examples,
footnote processing, etc), do the following. The results will be placed in
<code>doc/development/policy/svn-dev.html</code>:</p>

<pre class="shell" xml:space="preserve">
./bin/lore/lore -p --config template=doc/howto/template.tpl \
   doc/development/policy/svn-dev.xhtml
</pre>

<p>Note that hyperlinks to other documents may not be quite right unless you
include a <q>-l</q> argument to <code>bin/lore/lore</code>. Links in the
.xhtml file are to .xhtml targets: when the .xhtml is turned into .html, the
link targets are supposed to be turned into .html also. In addition to this,
Lore markup of the form &lt;code class=&quot;API&quot;&gt; is supposed to
turn into a link to the corresponding API reference page. These links will
probably be wrong unless the correct base URL is provided to Lore.</p>

<h2>Emacs<a name="auto6"/></h2>

<p>A minor mode for development with Twisted using Emacs is available.  See
<code>emacs/twisted-dev.el</code> for several utility functions which make
it easier to grep for methods, run test cases, etc.</p>

<h2>Building Debian packages<a name="auto7"/></h2>

<p>Our support for building Debian packages has fallen into disrepair.  We
would very much like to restore this functionality, but until we do so, if
you are interested in this, you are on your own.  See
<a href="http://stdeb.python-hosting.com/" shape="rect">stdeb</a> for one possible approach
to this.</p>

</div>

    <p><a href="../../howto/index.html">Index</a></p>
    <span class="version">Version: 9.0.0</span>
  </body>
</html>