Required items

Directories

To develop a plugin you need to create a few directories to keep things together.

So let's create following directories:

./helloworld-plugin/
./helloworld-plugin/helloworld/

Main plugin

The first step is to generate the main module for this plugin. We will construct a simple plugin that will display "Hello world!" on the screen when accessed through the /helloworld URL. The plugin also provides a "Hello" button that is, by default, rendered on the far right in the main navigation bar.

You will also have to add special ​egg metadata to cater to trac's plugin loader. Create the directory
./TracHelloworld.egg-info and edit the file trac_plugin.txt underneath it, adding the following:

helloworld

First deployment

Now try to build the plugin. Run the command python setup.py bdist_egg in the directory where you created it. If everything went OK you should have a .egg file in ./dist directory.

Copy this .egg file to /[your trac env]/plugins directory. Restart the trac server. If you're using mod_python you have to restart Apache.

Now you should see Hello link at far right in main navigation bar when accessing your site. Click it.

Aftermath

Now you have successfully created your first egg. You can continue by reading EggCookingTutorial/AdvancedEggCooking to learn how to use templates in your plugins, and make its output look like other Trac pages.