Skip to main content

Computes "goodness" index for Python packages based on various empirical "kwalitee" factors

## Summary

The idea of the Cheesecake project is to rank Python packages based on various empirical “kwalitee” factors, such as:

• whether the package can be downloaded from PyPI given its name

• whether the package can be unpacked

• whether the package can be installed into an alternate directory

• existence of certain files such as README, INSTALL, LICENSE, setup.py etc.

• percentage of modules/functions/classes/methods with docstrings

• pylint score

• … and many others

Currently, the Cheesecake index is computed for invidual packages obtained through a variety of methods (detailed below). One of the goals of the Cheesecake project is to automatically compute the Cheesecake index for all packages uploaded to the PyPI Cheese Shop (possibly at upload time) and to maintain a collection of Web pages with statistics related to the various indexes of the packages.

Cheesecake currently computes 3 types of indexes:

• installability index

• documentation index

• code kwalitee index

The algorithms for computing each index type are detailed below.

## Why Cheesecake?

The concept of “kwalitee” originated in the Perl community. Here’s a relevant quote:

• It looks like quality, it sounds like quality, but it’s not quite quality.*

Kwalitee is an empiric measure of how good a specific body of code is. It defines quality indicators and measures the code along them. It is currently used by the CPANTS Testing Service to evaluate the ‘goodness’ of CPAN packages.

Since the Python package repository (aka PyPI) is hosted at the Cheese Shop, it stands to reason that the quality indicator of a PyPI package should be called the Cheesecake index!

## Usage examples

To compute the Cheesecake index for a given project, run the cheesecake_index script from the command line and indicate either:

In all cases, the cheesecake script will attempt to download the package if necessary, then to unpack it in a sandbox directory (/tmp/cheesecake_sandbox by default). If either of these operations fails, the Cheesecake index for the package will be 0. If the package can be successfully unpacked, the cheesecake script will compute the values for a variety of indexes detailed in the algorithm given at the end of this file.

If the package can be successfully downloaded and unpacked, a log file is created in the system /tmp directory and named <package>.log (e.g. the log file for twill-0.7.4.tar.gz is /tmp/twill-0.7.4.tar.gz.log). The log file is automatically deleted after the Cheesecake index is computed, except for situations when errors have occured.

Command-line examples:

1. Compute the Cheesecake index for the Durus package by using setuptools utilities to download the package from PyPI:

python cheesecake_index --name=Durus
2. Compute the Cheesecake index for the Durus package by indicating its URL:

python cheesecake_index --url=http://www.mems-exchange.org/software/durus/Durus-3.1.tar.gz
3. Compute the Cheesecake index for the twill package by indicating its path on the local file system:

python cheesecake_index --path=/tmp/twill-latest.tar.gz
4. To increase the verbosity of the output, use the -v or –verbose option. For more options, run cheesecake_index with -h or –help.

## Requirements

• pylint is required for part of the code kwalitee index computation

• setuptools is required for the installability index computation

## Unit tests

We use nose for automatic testing of our project, so if you want to test Cheesecake on your machine, please install that first. Running the standard set of Cheesecake unit test is as easy as:

python setup.py test

This command is equivalent to:

nosetests --verbose --with-doctest --doctest-tests --include unit --exe

We also have a set of functional tests, which can be run by issuing this command:

nosetests --verbose --include functional

Functional tests can take a bit longer to complete, as they test cheesecake_index script as a whole (as opposed to testing modules and classes separately).

If you happen to find any of our tests failing, please don’t hesitate to open a ticket on GitHub.

## License

Cheesecake is licensed under the Python Software Foundation license, the same license that governs Python itself. The text of the license is available in the LICENSE file in the source code distribution and can also be downloaded from http://www.opensource.org/licenses/PythonSoftFoundation.php.

## Authors contact info

Grig Gheorghiu

Email:

<grig at gheorghiu dot net>

Web site:

http://agiletesting.blogspot.com

Michal Kwiatkowski

Email:

<michal at trivas.pl>

Web site:

http://trivas.pl

Note: clipart for the cheesecake slice logo used with permission from Kazumi Hatasa, Director, the Japanese School at Middlebury College, Purdue University.

## Algorithm for computing the Cheesecake index

The overall Cheesecake score is the sum of values of 3 main indexes (installability, documentation and code kwalitee). The values of these indexes rely on values of their subindexes and so on. The whole index tree and corresponding values for each leaf are presented below:

• Installability

• package is listed on and can be downloaded from PyPI: 50

• package can be downloaded from given URL: 25

• package can be unpacked without problems: 25

• unpacked package directory is the same as package name: 15

• package has setup.py: 25

• package can be installed to given directory via “setup.py install”: 50

• package contains generated files, like .pyc: -20

• Documentation

• package contains files listed below

• README: 30

• LICENCE/COPYING: 30 [1]

• ANNOUNCE/CHANGELOG: 20 [1]

• INSTALL: 20

• AUTHORS: 10

• FAQ: 10

• NEWS: 10

• THANKS: 10

• TODO: 10

• package contains directories listed below

• doc/docs: 30 [1]

• test/tests: 30 [1]

• demo/example/examples: 10 [1]

• code is documented by docstrings: 100 [2]

• docstrings have proper formatting (like epytext or reST): 30 [3]

• Code Kwalitee

• package has high pylint score: 50

• package has unit tests: 30

• (optional) package doesn’t follow PEP8 conventions [4]: -2 for each error type and -1 for each warning type

The final score depends on how well the package scores for all indexes listed above. The score is presented in absolute range (number of points) and relative (percent of points obtained compared to maximum possible points).

## Sample output

\$ python cheesecake_index -n nose --with-pep8
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)
unpack .................................  25  (package unpacked successfully)
unpack_dir .............................  15  (unpack directory is nose-0.9.1 as expected)
setup.py ...............................  25  (setup.py found)
install ................................  50  (package installed in /tmp/cheesecakeOzL_mb/tmp_install_nose-0.9.1)
generated_files ........................   0  (0 .pyc and 0 .pyo files found)
---------------------------------------------
INSTALLABILITY INDEX (ABSOLUTE) ........ 165
INSTALLABILITY INDEX (RELATIVE) ........ 100  (165 out of a maximum of 165 points is 100%)

required_files ......................... 110  (4 files and 2 required directories found)
docstrings .............................  43  (found 139/329=42.25% objects with docstrings)
formatted_docstrings ...................   0  (found 53/329=16.11% objects with formatted docstrings)
---------------------------------------------
DOCUMENTATION INDEX (ABSOLUTE) ......... 153
DOCUMENTATION INDEX (RELATIVE) .........  44  (153 out of a maximum of 350 points is 44%)

unit_tested ............................  30  (has unit tests)
pylint .................................  37  (pylint score was 7.29 out of 10)
pep8 ................................... -16  (pep8.py check: 7 error types, 2 warning types)
---------------------------------------------
CODE KWALITEE INDEX (ABSOLUTE) .........  51
CODE KWALITEE INDEX (RELATIVE) .........  64  (51 out of a maximum of 80 points is 64%)

=============================================
OVERALL CHEESECAKE INDEX (ABSOLUTE) .... 369
OVERALL CHEESECAKE INDEX (RELATIVE) ....  62  (369 out of a maximum of 595 points is 62%)

## Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

### Source Distribution

Cheesecake-0.6.2.tar.gz (52.0 kB view hashes)

Uploaded source

### Built Distribution

Cheesecake-0.6.2-py2.7.egg (118.1 kB view hashes)

Uploaded 2 7