Skip to content

Latest commit

 

History

History
65 lines (53 loc) · 2.45 KB

devel-notes.rst

File metadata and controls

65 lines (53 loc) · 2.45 KB

Code organization

The code is organized as follow:

$ tree -L 1
.
├── data
├── devel-notes.rst
├── doc
├── examples
├── fake_pyrex
├── LICENSE.txt
├── MANIFEST.in
├── pytpm
├── PyTPM.egg-info
├── README.txt
├── RELEASE_HOWTO.rst
├── setup-devel.py
├── setup.py
├── src
  1. Directory data is used for scripts used while developing the code. These are used for generating tests data, summarizing test results and others.

  2. The fake_pyrex directory exists so that distribute will run Cython on the Cython source file and generate the C extension. See setup-devel.py for more details.

  3. I use distribute so that I can run python setup-devel.py test after making any changes, without having to install the package first. This is possible with distribute/setuptools but not with distutils.

  4. To make the above possible, I have the pytpm/ directory with all the contents of the module and a directory pytpm/tests/ that contain the tests. The argument test_suite in setup-devel.py is set to this directory.

    With this setup, when I type python setup-devel.py test, Cython is run on the Cython code in src/, then it is compiled to form the module, which is then copied to pytpm. Then the tests inside the pytpm.tests sub-package is run.

  5. While developing I do not want to keep compiling the C library. For this I created a static library of TPM in src/tpm/libtpm.a and then ask setuptools to link to this library. This is done in setup-devel.py. See it for more comments.

  6. When shipping the code I want to compile the C library. Also I do not want Cython to be run. Instead the Cython generated C file should be directly used. This ensures that any version mismatch with user's Cython doesn't cause any problems. In fact the source distribution (sdist) does not include the Cython source code. This is achieved by setup.py.

So in short, if you want to work on the Cython code, then create a static libtpm.a file in src/tpm and then use setup-devel.py. Run python setup-devel.py test. This will create the Cython generated C file. If you just want to test/install it then simply run python setup.py test/install. This will use the existing Cython generated C file and will compile all the C files in src/tpm/.