Edgewall Software

Changes between Version 23 and Version 24 of TracDev/DevelopmentEnvironmentSetup


Ignore:
Timestamp:
Feb 22, 2010, 4:48:46 AM (14 years ago)
Author:
ryano@…
Comment:

Updated with some info from TracDev/DevelopmentWithEclipseAndPyDev after removing redundant information on that page.

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/DevelopmentEnvironmentSetup

    v23 v24  
     1[[PageOutline(2-5,Contents,pullout)]]
    12= Developer setup for Trac =
    2 This tutorial assumes you have SVN installed.  If you don't have SVN installed please go to the [http://subversion.tigris.org/ Subversion] website and follow the directions of installation there.
    33
    44== Where to go for more information ==
     
    1212 *  For the functional test, please review [../FunctionalTests]
    1313
    14 == Setting up the environment ==
     14== Installing the development tools ==
    1515Before we begin to develop in Trac, or even download Trac code, first create a standalone environment.
    16 
    17 Note: if you planning to develop using Eclipse you should also check [wiki:TracDev/DevelopmentWithEclipseAndPyDev Development with Eclipse and PyDev].
    1816
    1917=== Create a working directory ===
     
    2927'''Note:''' I don't create a directory called 'trac' yet. That comes later!  In the meantime, cd (change directory) to your projects directory.
    3028
     29=== Get Subversion ===
     30This tutorial assumes you have SVN installed.  If you don't have SVN installed please go to the [http://subversion.tigris.org/ Subversion] website and follow the directions of installation there.
     31
     32=== Get Python ===
     33
     34On Linux, it is usually best to install Python using the package manager for your distribution. For example, on a distribution utilizing the Apt package manager (Debian, Ubuntu):
     35{{{
     36sudo apt-get install python2.6
     37}}}
     38
     39On Windows, there are a number of Python distributions available. Some of the available options are:
     40 * The official Python distribution from [http://www.python.org/download/ python.org].
     41 * ActiveState [http://www.activestate.com/activepython/ ActivePython]
     42
    3143=== Get easy_install ===
    3244You may already have easy_install if you have "setuptools" installed. Just make sure its version is >= 0.6c10. Previous versions do not work correctly with SVN 1.6.
     
    3749}}}
    3850
    39 === Get virtual env ===
     51To test if the installation was successful, try typing from command-line prompt:
     52{{{
     53easy_install --help
     54}}}
     55
     56=== Get virtualenv ===
    4057From the command-line prompt type:
    4158{{{
     
    6178You'll see your command-line prompt has changed.  That means our environment is ready for Trac.
    6279
    63 
    6480=== Upgrade Setuptools ===
    6581Just to be sure you have a recent enough version of setuptools you may try to upgrade them (this was necessary on Ubuntu 10.04 Beta). For more options on upgrading packages with easy_install see [http://peak.telecommunity.com/DevCenter/EasyInstall#upgrading-a-package upgrading a package].
     
    6884}}}
    6985
     86== Developing with Eclipse and !PyDev ==
     87If you planning to develop using Eclipse you should also read the [TracDev/DevelopmentWithEclipseAndPyDev Development with Eclipse and PyDev] page, after installing and configuring Trac in the next section.
    7088
    7189== Installing and configuring Trac ==
     
    96114'''note:''' Don't do this in production!
    97115
    98 === Installing the trackdeveloperplugin ===
     116=== Installing the tracdeveloperplugin ===
    99117From the command-line prompt:
    100118{{{
     
    121139}}}
    122140
     141=== Debugging Plugins ===
     142To debug a plugin, install it to your test environment using the command:
     143 {{{
     144 $ python setup.py develop -md /path/to/projenv/plugins
     145 }}}
     146If 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.
     147
    123148=== Web stuff ===
    124149Switch to your browser and go to this URL:
     
    134159  - level to debug
    135160
    136 === Alternative frontend: mod_python ===
    137 
    138 Virtualenv can also be used with Apache and mod_python, but as mod_python will be a system install it will not be aware of the virutalenv without some configuration. For development this is useful as one Apache can serve various development versions in a more permanent way. This method will use the system Python, but will add the libraries from the virtualenv.
    139 
    140 '''Step 1:''' Make a new frontend script that for instance can be stored in the virtualenv 'bin' directory.
    141 
    142 {{{
    143 #!python
    144 #myvirtualtrac.py
    145 
    146 import os
    147 import site
    148 site.addsitedir('/path/to/my/virtualenv/lib/python2.4/site-packages')
    149 
    150 from trac.web.modpython_frontend import handler
    151 }}}
    152 
    153 '''Step 2:''' Update Apache config to use this script - add or update options according to the default mod_python setup like for instance found in TracModPython.
    154 
    155 {{{
    156 # Extend the path so Apache will find your script on path
    157 PythonPath "['/path/to/my/virtualenv/bin'] + sys.path"
    158 
    159 # Make mod_python use new frontend instead of trac.web.modpython_frontend
    160 PythonHandler myvirtualtrac
    161 }}}
    162 
    163 === Alternative frontend: mod_wsgi ===
    164 
    165 Using Apache, mod_wsgi is a very good alternative to mod_python. Setting this up follows the same pattern, but for development escpecially there is one major advantage: It can quite easily be set up to auto-reload on code changes.
    166 
    167 '''Step 1:''' Update a default TracModWsgi setup to make a deamonised process, and as of mod_wsgi 2.0 (this setup depends on >= 2.0) there is built-in support for custom paths and similar. Example of a full `VirtualHost` configuration:
    168 
    169 {{{
    170 <VirtualHost *:80>
    171     ServerName virtualtrac.local
    172 
    173     # Update user and group to be whatever on your system is intended to run the deamon
    174     # Update the paths to point to virtualenv site-packages (for trac+++) and bin (for script)
    175     WSGIDaemonProcess virtualtrac user=www group=www threads=25 python-path=/path/to/my/virtualenv/lib/python2.4/site-packages:/path/to/my/virtualenv/bin
    176 
    177     WSGIScriptAlias / /path/to/my/virtualenv/bin/virtualtrac.wsgi
    178 
    179     <Location />
    180       WSGIReloadMechanism Process
    181       WSGIProcessGroup virtualtrac
    182       WSGIApplicationGroup %{SERVER}
    183       Order deny,allow
    184       Allow from all
    185     </Location>
    186 
    187     # Authentication
    188     <LocationMatch (/[^/.]+/login)>
    189       # Note: Change settings with regards to auth method, paths and domain
    190       AuthType Digest
    191       AuthName "virtualtrac"
    192       AuthDigestDomain /trac http://virtualtrac.local
    193       AuthDigestProvider file
    194       AuthUserFile /path/to/access.htdigest
    195       Require valid-user
    196     </LocationMatch>
    197 
    198 </VirtualHost>
    199 }}}
    200 
    201 '''Step 2:''' Go to http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode and save the long Python script that follows the text 'Example code for such an automatic restart mechanism...'. Save it as `/path/to/my/virtualenv/bin/monitor.py`
    202 
    203 '''Step 3:''' A basic WSGI frontend script, save as `/path/to/my/virtualenv/bin/virtualtrac.wsgi`
    204 
    205 {{{
    206 #!python
    207 
    208 import sys
    209 sys.stdout = sys.stderr
    210 
    211 import os
    212 os.environ['TRAC_ENV_DIR'] = "/path/to/trac/project"
    213 # or, alternatively for multiple projects
    214 #os.environ['TRAC_ENV_PARENT_DIR'] = "/parent/path/to/many/projects"
    215 os.environ['PYTHON_EGG_CACHE'] = '/path/to/a/temp/to/cache/eggs'
    216 
    217 import trac.web.main
    218 
    219 import monitor
    220 monitor.start(interval=1.0)
    221 # Additionally monitor easy-install.pth to restart whenever installs are done
    222 monitor.track('/path/to/my/virtualenv/lib/python2.4/site-packages/easy-install.pth')
    223 
    224 application = trac.web.main.dispatch_request
    225 }}}
     161=== Alternative frontends ===
     162To develop on Trac with Apache rather than the standalone tracd, see the [TracDev/AlternativeFrontends alternative frontends] page for information on using Apache with mod_python and mod_wsgi.