2014-02-15 18:30:54 +00:00
|
|
|
Hacking
|
|
|
|
=======
|
2009-07-24 23:00:45 -03:00
|
|
|
|
2014-02-15 18:30:54 +00:00
|
|
|
Python versions
|
|
|
|
---------------
|
2009-07-25 11:55:45 -03:00
|
|
|
|
2014-02-15 18:30:54 +00:00
|
|
|
Tito supports Python versions 2.4 (RHEL 5) and up.
|
|
|
|
See http://docs.python.org/dev/howto/pyporting.html
|
|
|
|
and http://python3porting.com/differences.html
|
|
|
|
for tips on writing portable Python code.
|
|
|
|
|
2014-02-15 22:55:14 +00:00
|
|
|
In particular, you must capture exceptions in a way that's
|
|
|
|
compatible with both python 2.4 and 3.x. For example:
|
|
|
|
|
|
|
|
try:
|
|
|
|
raise Exception()
|
|
|
|
except Exception:
|
|
|
|
import sys
|
|
|
|
exc = sys.exc_info()[1]
|
|
|
|
# Current exception is 'exc'.
|
|
|
|
pass
|
|
|
|
|
2014-02-15 18:30:54 +00:00
|
|
|
|
|
|
|
Tests
|
|
|
|
-----
|
|
|
|
|
2014-02-15 18:52:08 +00:00
|
|
|
To run all tests, install these packages:
|
2014-02-15 18:30:54 +00:00
|
|
|
|
2014-03-08 22:26:01 +00:00
|
|
|
* python-nose, python-pep8, and rpm-python
|
|
|
|
* python3-nose, python3-pep8, and rpm-python3
|
2014-02-28 14:59:15 +00:00
|
|
|
* createrepo
|
2014-02-15 18:52:08 +00:00
|
|
|
|
|
|
|
Then from the root of the project:
|
|
|
|
|
|
|
|
python ./runtests.py -vv
|
|
|
|
python3 ./runtests.py -vv test/unit
|
|
|
|
|
|
|
|
(Run only the unit tests on python3 since GitPython does not
|
|
|
|
support python3 yet.)
|
2011-10-15 13:17:07 -03:00
|
|
|
|
|
|
|
|
|
|
|
When developing code for tito there are a couple ways you can test:
|
|
|
|
|
|
|
|
"bin/tito-dev" is a script that will run code from the local checkout
|
|
|
|
rather than what is installed on the system.
|
|
|
|
|
2014-02-15 18:30:54 +00:00
|
|
|
And of course, you can always use the installed tito to replace
|
|
|
|
itself with a test build of the latest *committed* code in your
|
|
|
|
git HEAD.
|
2011-10-15 13:17:07 -03:00
|
|
|
|
|
|
|
tito build --rpm --test -i
|
|
|
|
|
|
|
|
If you screw anything up inside tito itself, you can just:
|
|
|
|
|
|
|
|
rpm -e tito
|
|
|
|
yum install tito
|
|
|
|
|
2014-02-15 18:30:54 +00:00
|
|
|
|
|
|
|
Code style
|
|
|
|
----------
|
|
|
|
|
|
|
|
Python3 does not allow mixing tabs and spaces for indentation.
|
|
|
|
http://docs.python.org/3.3/reference/lexical_analysis.html
|
|
|
|
|
|
|
|
You can force your editor to do the right thing by installing
|
|
|
|
a plugin for your editor from http://editorconfig.org/#download
|
|
|
|
|
|
|
|
For example, add the EditorConfig plugin for vim like this:
|
|
|
|
|
|
|
|
cd /tmp/
|
|
|
|
wget https://github.com/editorconfig/editorconfig-vim/archive/master.zip
|
|
|
|
unzip master.zip
|
|
|
|
mkdir ~/.vim
|
|
|
|
cp -r editorconfig-vim-master/* ~/.vim/
|