- Installing the development tools
- Developing with Eclipse and PyDev
- Installing and configuring Trac
- Further guidelines
Developer setup for Trac
Installing the development tools
Before we begin to develop in Trac, or even download Trac code, we create a standalone Python environment.
Create a working directory
Create a working directory for your development to take place in. For example, on Unix you might have:
On Windows you might have:
Note: Don't create a directory called 'trac' yet. That comes later.
This tutorial assumes you have Subversion (SVN) installed. If not, go to the Subversion website and follow the installation directions there.
On Linux, you'll usually want to install Python using the package manager for your distribution. For example, on a distribution utilizing the Apt package manager (Debian, Ubuntu):
$ sudo apt-get install python
You will also need some additional libraries:
$ sudo apt-get install python-subversion
On Windows, some of the available options are:
Mac OS X has Python pre-installed, but you probably want to install a newer version using a package manager such as Homebrew.
You'll already have
pip installed with Python ≥ 2.7.9. If you are running an earlier version of Python, first check whether
pip is already installed:
$ pip --version
Use get-pip.py if you need to install
You may already have
$ virtualenv --version
If you need to install
virtualenv, or you wish to upgrade the package:
$ pip install -U virtualenv
You may need to prefix the command with
sudo on Unix platforms.
Set up a virtual environment
From the command-line prompt type:
$ virtualenv pve $ source pve/bin/activate
or for Windows:
# python -m virtualenv pve # cmd /k Scripts\activate.bat
You'll see your command-line prompt has changed. That means your environment is ready for Trac.
Upgrade the dependencies in your environment.
$ pip install -U pip setuptools wheel
Developing with Eclipse and PyDev
If you are planning to develop using Eclipse, you should also read the Development with Eclipse and PyDev page, after installing and configuring Trac in the next section.
Installing and configuring Trac
You should get the Trac source code from one of the TracRepositories. For example, to checkout from Subversion using the command-line:
$ svn co https://svn.edgewall.org/repos/genshi/trunk genshi-trunk $ svn co https://svn.edgewall.org/repos/trac/trunk/ trac-trunk
Install the packages in development mode:
$ pip install -e genshi-trunk $ pip install -e trac-trunk
For Trac ≥ 1.3.2 you'll need Jinja2:
$ git clone https://github.com/pallets/jinja.git jinja2 $ pip install -e jinja2
Create a Trac environment
From the command-line prompt:
$ trac-admin tracenv initenv "TracDev" sqlite:db/trac.db
Grant full access to anonymous users
$ trac-admin tracenv permission add anonymous TRAC_ADMIN
Note: Don't do this in production!
Install the TracDeveloperPlugin (optional)
$ svn co https://trac-hacks.org/svn/tracdeveloperplugin/trunk/ tracdeveloperplugin $ pip install tracdeveloperplugin/
Start Trac in development mode
$ tracd -r -s --port 8000 tracenv
-r command puts Trac into refresh mode so your code changes will immediately take effect. See also the auto_reload option in trac.ini, which causes template changes to take effect immediately.
tracd or work in the virtual environment, you must switch to the virtual environment each time a new shell is opened:
$ cd /path/to/projects $ source pve/bin/activate
To develop a plugin, checkout the source and install it in development mode using the command:
$ pip install -e /path/to/plugin/src
If you are experiencing trouble debugging Trac code, make sure that
PYTHONPATH in project properties doesn't contain pointers to other Trac sources. Otherwise those sources will be used instead of the checked-out sources.
Open Trac in your browser
Switch to your browser and go to
Now do the following:
- Go to web admin
- Click on Admin
- Set logging:
- Set type to
- Set level to
- Set type to
To develop on Trac with Apache rather than the standalone
tracd, see the alternative frontends page for information on using Apache with mod_python and mod_wsgi.
Check the milestones pages to see if there are any specific requirements for the version you are developing against. Specifically, for Trac 1.3.2+, you need Jinja2 2.9.3 or later. See milestone:1.3.2 for more information.
The (automated) tests will require additional packages that may or may not be installed with your OS/Python distribution.