Changes between Version 23 and Version 24 of TracDev/DevelopmentEnvironmentSetup
- Timestamp:
- Feb 22, 2010, 4:48:46 AM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracDev/DevelopmentEnvironmentSetup
v23 v24 1 [[PageOutline(2-5,Contents,pullout)]] 1 2 = 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.3 3 4 4 == Where to go for more information == … … 12 12 * For the functional test, please review [../FunctionalTests] 13 13 14 == Setting up the environment==14 == Installing the development tools == 15 15 Before 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].18 16 19 17 === Create a working directory === … … 29 27 '''Note:''' I don't create a directory called 'trac' yet. That comes later! In the meantime, cd (change directory) to your projects directory. 30 28 29 === Get Subversion === 30 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. 31 32 === Get Python === 33 34 On 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 {{{ 36 sudo apt-get install python2.6 37 }}} 38 39 On 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 31 43 === Get easy_install === 32 44 You 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. … … 37 49 }}} 38 50 39 === Get virtual env === 51 To test if the installation was successful, try typing from command-line prompt: 52 {{{ 53 easy_install --help 54 }}} 55 56 === Get virtualenv === 40 57 From the command-line prompt type: 41 58 {{{ … … 61 78 You'll see your command-line prompt has changed. That means our environment is ready for Trac. 62 79 63 64 80 === Upgrade Setuptools === 65 81 Just 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]. … … 68 84 }}} 69 85 86 == Developing with Eclipse and !PyDev == 87 If 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. 70 88 71 89 == Installing and configuring Trac == … … 96 114 '''note:''' Don't do this in production! 97 115 98 === Installing the trac kdeveloperplugin ===116 === Installing the tracdeveloperplugin === 99 117 From the command-line prompt: 100 118 {{{ … … 121 139 }}} 122 140 141 === Debugging Plugins === 142 To debug a plugin, install it to your test environment using the command: 143 {{{ 144 $ python setup.py develop -md /path/to/projenv/plugins 145 }}} 146 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. 147 123 148 === Web stuff === 124 149 Switch to your browser and go to this URL: … … 134 159 - level to debug 135 160 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 === 162 To 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.