root/trunk/README

Revision 195, 12.1 kB (checked in by anonymous, 1 year ago)

#42

Line 
1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 Cheesecake: How tasty is your code?
3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4
5 .. contents:: **Table of Contents**
6
7 Summary
8 -------
9
10 The idea of the Cheesecake project is to rank Python packages based on various
11 empirical "kwalitee" factors, such as:
12
13  * whether the package can be downloaded from PyPI given its name
14  * whether the package can be unpacked
15  * whether the package can be installed into an alternate directory
16  * existence of certain files such as README, INSTALL, LICENSE, setup.py etc.
17  * percentage of modules/functions/classes/methods with docstrings
18  * pylint score
19  * ... and many others
20
21 Currently, the Cheesecake index is computed for invidual packages obtained
22 through a variety of methods (detailed below). One of the goals of the
23 Cheesecake project is to automatically compute the Cheesecake index for
24 all packages uploaded to the PyPI Cheese Shop (possibly at upload time) and
25 to maintain a collection of Web pages with statistics related to the
26 various indexes of the packages.
27
28 Cheesecake currently computes 3 types of indexes:
29
30  * installability index
31  * documentation index
32  * code kwalitee index
33
34 The algorithms for computing each index type are detailed below.
35
36 Why Cheesecake?
37 ---------------
38
39 The concept of "kwalitee" originated in the Perl community. Here's a relevant
40 quote:
41
42   * It looks like quality, it sounds like quality, but it's not quite quality.*
43
44 Kwalitee is an empiric measure of how good a specific body of code is. It
45 defines quality indicators and measures the code along them. It is currently
46 used by the `CPANTS Testing Service <http://cpants.dev.zsi.at/index.html>`_
47 to evaluate the 'goodness' of CPAN packages.
48
49 Since the Python package repository (aka `PyPI <http://www.python.org/pypi>`_)
50 is hosted at the Cheese Shop,
51 it stands to reason that the quality indicator of a PyPI package should be
52 called the Cheesecake index!
53
54 Usage examples
55 --------------
56
57 To compute the Cheesecake index for a given project, run the cheesecake_index
58 script from the command line and indicate either:
59
60  * the package short name (e.g. twill) or
61  * the package URL (e.g. http://darcs.idyll.org/~t/projects/twill-0.7.4.tar.gz) or
62  * the package path on the file system (e.g. /tmp/twill-latest.tar.gz)
63
64 In all cases, the cheesecake script will attempt to download the package
65 if necessary, then to unpack it in a sandbox directory (/tmp/cheesecake_sandbox
66 by default). If either of these operations fails, the Cheesecake index for
67 the package will be 0. If the package can be successfully unpacked, the
68 cheesecake script will compute the values for a variety of indexes detailed
69 in the algorithm given at the end of this file.
70
71 If the package can be successfully downloaded and unpacked, a log file is
72 created in the system /tmp directory and named <package>.log (e.g. the log file
73 for twill-0.7.4.tar.gz is /tmp/twill-0.7.4.tar.gz.log).
74 The log file is automatically deleted after the Cheesecake index is
75 computed, except for situations when errors have occured.
76
77 Command-line examples:
78
79  1. Compute the Cheesecake index for the Durus package by using setuptools
80     utilities to download the package from PyPI::
81
82       python cheesecake_index --name=Durus
83
84  2. Compute the Cheesecake index for the Durus package by indicating its URL::
85
86       python cheesecake_index --url=http://www.mems-exchange.org/software/durus/Durus-3.1.tar.gz
87
88  3. Compute the Cheesecake index for the twill package by indicating its path
89     on the local file system::
90
91       python cheesecake_index --path=/tmp/twill-latest.tar.gz
92
93  4. To increase the verbosity of the output, use the -v or --verbose option.
94     For more options, run cheesecake_index with -h or --help.
95
96 Requirements
97 ------------
98
99 * `pylint <http://www.logilab.org/projects/pylint>`_ is required for
100   part of the code kwalitee index computation
101 * `setuptools <http://peak.telecommunity.com/DevCenter/setuptools>`_ is
102   required for the installability index computation
103
104 Obtaining the source code
105 -------------------------
106
107 You can get the source code via svn::
108
109   svn co http://svn.pycheesecake.org/trunk cheesecake
110
111 *Note*: make sure you indicate the target directory when you do the svn checkout,
112 otherwise the cheesecake package files will be checked out directly in your
113 current directory.
114
115 You may want to modify your subversion client configuration to automatically
116 expand tags, like $Id$, $Author$ etc. To do so add following two lines to your
117 ``/.subversion/config``::
118
119   enable-auto-props = yes
120
121 in [miscellany] section, and::
122
123   *.py = svn:eol-style=native;svn:keywords=Author Date Id Revision
124
125 in [auto-props] section.
126
127 Documentation
128 -------------
129
130 The most recent code documentation should be always available
131 at http://agilistas.org/cheesecake/mk/docs/. You can also generate
132 this documentation directly from the Cheesecake sources. Run this command
133 from the main source directory::
134
135   sh support/generate_docs.sh .
136
137 :Note: Generating documentation requires `epydoc <http://epydoc.sourceforge.net/>`_
138        tool installed.
139
140 Unit tests
141 ----------
142
143 We use `nose <http://somethingaboutorange.com/mrl/projects/nose/>`_ for automatic
144 testing of our project, so if you want to test Cheesecake on your machine, please
145 install that first. Running the standard set of Cheesecake unit test is as easy as::
146
147   python setup.py test
148
149 This command is equivalent to::
150
151   nosetests --verbose --with-doctest --doctest-tests --include unit --exe
152
153 We also have a set of functional tests, which can be run by issuing this command::
154
155   nosetests --verbose --include functional
156
157 Functional tests can take a bit longer to complete, as they test cheesecake_index
158 script as a whole (as opposed to testing modules and classes separately).
159
160 If you happen to find any of our tests failing, please don't hesitate to contact
161 us, either via
162 `cheesecake-devel mailing list <http://lists2.idyll.org/listinfo/cheesecake-dev>`_
163 or via `Cheesecake Trac <http://pycheesecake.org/>`_.
164
165 Buildbot
166 --------
167
168 A buildbot is happily running svn updates and unit tests. Check it out
169 `here <http://agilistas.org:8888/>`_.
170
171 Mailing lists
172 -------------
173
174 * Developer mailing list: http://lists2.idyll.org/listinfo/cheesecake-dev
175 * User mailing list: http://lists2.idyll.org/listinfo/cheesecake-users
176
177 License
178 -------
179
180 Cheesecake is licensed under the Python Software Foundation license,
181 the same license that governs Python itself. The text of the license is
182 available in the ``LICENSE`` file in the source code distribution and
183 can also be downloaded from
184 http://www.opensource.org/licenses/PythonSoftFoundation.php.
185
186 Authors contact info
187 --------------------
188
189 Grig Gheorghiu
190
191 :Email: <grig at gheorghiu dot net>
192 :Web site: http://agiletesting.blogspot.com
193
194 Michal Kwiatkowski
195
196 :Email: <ruby at joker.linuxstuff.pl>
197 :Web site: http://joker.linuxstuff.pl
198
199 Note: clipart for the cheesecake slice logo used with permission from
200 Kazumi Hatasa, Director, the Japanese School at Middlebury College,
201 Purdue University.
202
203 Algorithm for computing the Cheesecake index
204 --------------------------------------------
205
206 The overall Cheesecake score is the sum of values of 3 main indexes
207 (installability, documentation and code kwalitee). The values of these
208 indexes rely on values of their subindexes and so on. The whole index tree
209 and corresponding values for each leaf are presented below:
210
211 * Installability
212
213   * package is listed on and can be downloaded from PyPI: 50
214   * package can be downloaded from given URL: 25
215   * package can be unpacked without problems: 25
216   * unpacked package directory is the same as package name: 15
217   * package has setup.py: 25
218   * package can be installed to given directory via "setup.py install": 50
219   * package contain generated files, like .pyc: -20
220
221 * Documentation
222
223   * package contain files listed below
224
225     * README: 30
226     * LICENCE/COPYING: 30 [#oneof]_
227     * ANNOUNCE/CHANGELOG: 20 [#oneof]_
228     * INSTALL: 20
229     * AUTHORS: 10
230     * FAQ: 10
231     * NEWS: 10
232     * THANKS: 10
233     * TODO: 10
234
235   * package contain directories listed below
236
237     * doc/docs: 30 [#oneof]_
238     * test/tests: 30 [#oneof]_
239     * demo/example/examples: 10 [#oneof]_
240
241   * code is documented by docstrings: 100 [#docstrings]_
242   * docstrings have proper formatting (like epytext or reST): 30 [#formatted]_
243
244 * Code Kwalitee
245
246   * package has high pylint score: 50
247   * package has unit tests: 30
248   * (optional) package doesn't follow PEP8 conventions [#PEP8]_: -2 for each error type and -1 for each warning type
249
250 The final score depends on how well the package scores for all indexes
251 listed above. The score is presented in absolute range (number of points)
252 and relative (percent of points obtained compared to maximum possible points).
253
254 .. [#oneof] It is enough for a package to contain only one of listed files.
255 .. [#docstrings] Number of points is proportional to percent of documentable objects
256    (module, class or function) that have docstrings. For example, if
257    you have 50 documentable objects and 32 of them have docstrings
258    your code will get 64 points (because 64% of objects are documented).
259 .. [#formatted] Number of points depends on number of docstrings that are found
260    to contain one of known markup. Currently ReST, epytext and javadoc are
261    recognized. We give 10 points for 25% of formatted docstrings, 20 points
262    for 50% and 30 points for 75%.
263 .. [#PEP8] PEP8 defines a good coding style for Python, see
264    `PEP8 document <http://www.python.org/dev/peps/pep-0008/>`_ for details.
265
266 Sample output
267 -------------
268
269 ::
270
271     $ python cheesecake_index -n nose --with-pep8
272     py_pi_download .........................  50  (downloaded package nose-0.9.1.tar.gz following 1 link from http://somethingaboutorange.com/mrl/projects/nose/nose-0.9.1.tar.gz)
273     unpack .................................  25  (package unpacked successfully)
274     unpack_dir .............................  15  (unpack directory is nose-0.9.1 as expected)
275     setup.py ...............................  25  (setup.py found)
276     install ................................  50  (package installed in /tmp/cheesecakeOzL_mb/tmp_install_nose-0.9.1)
277     generated_files ........................   0  (0 .pyc and 0 .pyo files found)
278     ---------------------------------------------
279     INSTALLABILITY INDEX (ABSOLUTE) ........ 165
280     INSTALLABILITY INDEX (RELATIVE) ........ 100  (165 out of a maximum of 165 points is 100%)
281
282     required_files ......................... 110  (4 files and 2 required directories found)
283     docstrings .............................  43  (found 139/329=42.25% objects with docstrings)
284     formatted_docstrings ...................   0  (found 53/329=16.11% objects with formatted docstrings)
285     ---------------------------------------------
286     DOCUMENTATION INDEX (ABSOLUTE) ......... 153
287     DOCUMENTATION INDEX (RELATIVE) .........  44  (153 out of a maximum of 350 points is 44%)
288
289     unit_tested ............................  30  (has unit tests)
290     pylint .................................  37  (pylint score was 7.29 out of 10)
291     pep8 ................................... -16  (pep8.py check: 7 error types, 2 warning types)
292     ---------------------------------------------
293     CODE KWALITEE INDEX (ABSOLUTE) .........  51
294     CODE KWALITEE INDEX (RELATIVE) .........  64  (51 out of a maximum of 80 points is 64%)
295
296
297     =============================================
298     OVERALL CHEESECAKE INDEX (ABSOLUTE) .... 369
299     OVERALL CHEESECAKE INDEX (RELATIVE) ....  62  (369 out of a maximum of 595 points is 62%)
300
301 Case study: Cleaning up PyBlosxom
302 ---------------------------------
303
304 Many thanks to Will Guaraldi for writing
305 `this article <http://pycheesecake.org/wiki/CleaningUpPyBlosxom>`_ about his
306 experiences in using Cheesecake to clean up and improve the structure of his
307 PyBlosxom package.
308    
309 Future plans
310 ------------
311 Cheesecake is under very active development. The immediate goal is to add the unit test
312 index measurement, followed by other metrics inspired from the
313 `kwalitee indicators <http://cpants.dev.zsi.at/kwalitee.html>`_.
314 Please edit the `IndexMeasurementIdeas <http://pycheesecake.org/wiki/IndexMeasurementIdeas>`_
315 Wiki page to add things that you would like to see covered
316 by the Cheesecake metrics.
317
318 .. footer:: Last modified: 31 Jan 2007 by `Michal Kwiatkowski <http://joker.linuxstuff.pl>`_.
Note: See TracBrowser for help on using the browser.