Edgewall Software

Version 11 (modified by Piotr Kuczynski <piotr.kuczynski@…>, 16 years ago) ( diff )

genshi link

How to develop Trac with Eclipse PyDev

Installing and configuring Python

Python

Download and install latest Python.

easy_install

Go to installing-easy-install and follow the instructions there.

However, most of the time you just take the file ez_setup.py, save it as ez_setup.py on your hard drive, and then from the command-line prompt type:

python ez_setup.py

To test if the installation was successful, try typing from command-line prompt:

easy_install --help

If it doesn't work, check to make sure your PATH includes the appropriate C:
Python2X
Scripts directory. See more info on Windows Notes at easy_install manual page.

Genshi

Install Genshi using easy_install:

easy_install genshi 

You can also install using Genshi windows installer or python egg if you prefer.

Installing and configuring Trac

Downloading trac

From the command-line prompt:

svn co http://svn.edgewall.org/repos/trac/trunk/ trac-trunk
svn co http://svn.edgewall.org/repos/genshi/trunk/ genshi-trunk
cd trac-trunk
python setup.py develop 
cd ../genshi-trunk
python setup.py develop
cd ..

Setuptools

Then build the setuptools info file from the command line

$ set PYTHONPATH=c:\path\to\your\trac\sources
$ python setup.py egg_info

This is of course a bit tricky if you don't have trac installed in system so workflow is a bit different:

$ set PYTHONPATH=c:\path\to\your\trac\sources
$ python
>>> import trac.admin.console
>>> trac.admin.console.run(['/path/to/myproject', 'initenv'])

Creating test trac environment

From the command-line prompt:

trac-admin /path/to/myproject initenv

note: Press return for every option.

Make anonymous users have full access

trac-admin test permission add anonymous TRAC_ADMIN

note: Don't do this in production!

Installing and configuring Eclipse

  1. Install Eclipse (3.3 or newer will do)
  2. Install PyDev
  3. Also either Subclipse or Subversive is good to have for integrated support to SVN.
  1. In Eclipse, make sure that the PYTHONPATH in the project properties dialog includes the sources for trac.
  1. Create an initial run configuration by clicking right on trac/web/standalone.py file, and choosing Run As→Python Run.

trac will complain that no environment has been set.

  1. Select Run→Open Run Dialog… and set the correct command line arguments in the arguments tab, eg.

—port 8000 /path/to/myproject
Note that the option —auto-reload will cause tracd to restart every time source code has been changed, but it seems to prevent debugging with pydev. This seems to have something to do way Trac reloads new instance as a child thread using "thread" library which doesn't seem to be compatible with pydev debugging. Googling revelead some hints that instead using "thread"-module you should use "threading"-module (higherlevel)

  1. You should now be able to run tracd, as well as to debug it using the same run configuration. To run the test cases, just click on a test folder and select Run→Python unit tests
  1. To debug a plugin, deploy it into your test environment via
    $ python setup.py develop -md /path/to/projenv/plugins
    

and then start the run configuration from above.

If you are experiencing troubles in debugging Trac code, make sure that PYTHONPATH in project properties doesn't contain pointers to other Trac sources. Otherwise those sources will be picked instead checked out.

Note: It could be wise to setup virtualenv and install genshi, babel etc. there. Then debugging is easier and it doesn't interfere with existing Trac sources.

Automatic translation compilation

If you want to setup automatic translation compilation it can be done very easily.

  1. Right click on trac project and select Properties. Select Builders. Click New. Select Program.
  1. Name builder, like 'Locale fi_FI builder'
  1. Main tab: Location: click Browse File System…. Select Python executable.
    Working Directory: set it to ${project_loc}
    Arguments: setup.py compile_catalog -f -l fi_FI (change to your locale)
  1. Refresh tab: Check Refresh resources upon completion.
    Select Spesific resources and select trac/locale/fi_FI (select your locale)
  1. Build Options tab: Check During auto builds.
    Check Specify working set of relevan resources.
    Click Specify resources…. select trac/locale/fi_FI (select your locale, same as in step 4).
    Name it like fi_FI locale.
  1. After modifying your message.po file you should get following output:
     running compile_catalog
     compiling catalog 'trac/locale\\fi_FI\\LC_MESSAGES\\messages.po' to 'trac/locale\\fi_FI\\LC_MESSAGES\\messages.mo'
    

And if Trac is running you will have changes immediately effective.

Thanks

Originally these instructions were posted on trac-dev list by Joachim Hoessler.

Attachments (1)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.