Changes between Version 39 and Version 40 of TracDev/DevelopmentEnvironmentSetup
- Timestamp:
- Apr 26, 2017, 4:25:49 AM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracDev/DevelopmentEnvironmentSetup
v39 v40 5 5 == Installing the development tools 6 6 7 Before we begin to develop in Trac, or even download Trac code, create a standaloneenvironment.7 Before we begin to develop in Trac, or even download Trac code, we create a standalone Python environment. 8 8 9 9 === Create a working directory 10 10 11 Create a projects or working directory for your development efforts. So for example on some systems,you might have:11 Create a working directory for your development to take place in. For example, on Unix you might have: 12 12 {{{ 13 / Users/myname/projects13 /home/<user>/projects 14 14 }}} 15 15 16 On Windows you wouldhave:16 On Windows you might have: 17 17 {{{ 18 18 C:\projects … … 23 23 === Get Subversion 24 24 25 This tutorial assumes you have Subversion (SVN) installed. If not, go to the [http://subversion.apache.org/ Subversion] website and follow the directions of installationthere.25 This tutorial assumes you have Subversion (SVN) installed. If not, go to the [http://subversion.apache.org/ Subversion] website and follow the installation directions there. 26 26 27 27 === Get Python 28 28 29 On Linux, it is in most cases best to install Python using the package manager for your distribution. For example, on a distribution utilizing the Apt package manager (Debian, Ubuntu):29 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): 30 30 {{{#!sh 31 sudo apt-get install python2.6 31 $ sudo apt-get install python 32 32 }}} 33 33 34 34 You will also need some additional libraries: 35 35 {{{#!sh 36 sudo apt-get install python-subversion36 $ sudo apt-get install python-subversion 37 37 }}} 38 38 … … 41 41 * The commercial [http://www.activestate.com/activepython/ ActivePython] from ActiveState. 42 42 43 Mac OS X 10.5 and later has Python >= 2.5 pre-installed.43 Mac OS X has Python pre-installed, but you probably want to install a newer version using a package manager such as [https://brew.sh/ Homebrew]. 44 44 45 === Get easy_install45 === Get pip 46 46 47 You will 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. 48 49 Otherwise go to [http://peak.telecommunity.com/DevCenter/EasyInstall#installing-easy-install installing-easy-install] and follow the instructions there. However, most of the time you just take the text at [http://peak.telecommunity.com/dist/ez_setup.py ez_setup.py]. For Python 2.4 and 2.5 read Section [https://pypi.python.org/pypi/setuptools#python-2-4-and-python-2-5-support Python 2.4 and Python 2.5 support], save it as `ez_setup.py` on your hard drive, then from the command-line prompt type: 47 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: 50 48 {{{#!sh 51 python ez_setup.py 49 $ pip --version 52 50 }}} 53 54 To test if the installation was successful: 55 {{{#!sh 56 easy_install --help 57 }}} 51 Use [https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py get-pip.py] if you need to install `pip`. 58 52 59 53 === Get virtualenv 60 54 61 From the command-line prompt type: 55 You may already have `virtualenv` installed. 62 56 {{{#!sh 63 python -m easy_install virtualenv 57 $ virtualenv --version 64 58 }}} 65 59 66 On Linux you may need to prepend `python` with `sudo`. 60 If you need to install `virtualenv`, or you wish to upgrade the package: 61 {{{#!sh 62 $ pip install -U virtualenv 63 }}} 64 65 You may need to prefix the command with `sudo` on Unix platforms. 67 66 68 67 === Set up a virtual environment … … 70 69 From the command-line prompt type: 71 70 {{{#!sh 72 virtualenv trac 73 cd trac 74 source bin/activate 71 $ virtualenv pve 72 $ source pve/bin/activate 75 73 }}} 76 74 77 75 or for Windows: 78 {{{ 79 python -m virtualenv trac 80 cd trac 81 cmd /k Scripts\activate.bat 76 {{{#!cmd 77 # python -m virtualenv pve 78 # cmd /k Scripts\activate.bat 82 79 }}} 83 84 If you have Trac installed in `/usr/lib` or `/usr/local/lib`, run the above virtualenv command with `--no-site-packages`.85 80 86 81 You'll see your command-line prompt has changed. That means your environment is ready for Trac. 87 82 88 === Upgrade Setuptools83 === Upgrade Dependencies 89 84 90 Just to be sure you have a recent enough version of setuptools, and if not, you should upgrade them. For more options on upgrading packages with `easy_install` see [http://peak.telecommunity.com/DevCenter/EasyInstall#upgrading-a-package upgrading a package]: 85 Upgrade the dependencies in your environment. 91 86 {{{#!sh 92 easy_install --upgrade setuptools 87 $ pip install -U pip setuptools wheel 93 88 }}} 94 89 … … 101 96 === Download Trac 102 97 103 You should get the Trac source code from one of the TracRepositories. For example, for Subversion from the command-line prompt:98 You should get the Trac source code from one of the TracRepositories. For example, to checkout from Subversion using the command-line: 104 99 {{{#!sh 105 svn co http://svn.edgewall.org/repos/trac/trunk/ trac-trunk 106 svn co http://svn.edgewall.org/repos/genshi/trunk/ genshi-trunk 107 cd genshi-trunk 108 python setup.py develop 109 cd ../trac-trunk 110 python setup.py develop 111 cd .. 100 $ svn co https://svn.edgewall.org/repos/genshi/trunk genshi-trunk 101 $ svn co https://svn.edgewall.org/repos/trac/trunk/ trac-trunk 112 102 }}} 113 103 114 === Create your test Trac environment 104 Install the packages in development mode: 105 {{{#!sh 106 $ pip install -e genshi-trunk 107 $ pip install -e trac-trunk 108 }}} 109 110 For Trac >= 1.3.2 you'll need Jinja2: 111 {{{#!sh 112 $ git clone https://github.com/pallets/jinja.git jinja2 113 $ pip install -e jinja2 114 }}} 115 116 === Create a Trac environment 115 117 116 118 From the command-line prompt: 117 119 {{{#!sh 118 trac-admin test initenv 120 $ trac-admin tracenv initenv "TracDev" sqlite:db/trac.db 119 121 }}} 120 121 '''Note:''' Press return for every option.122 122 123 123 === Grant full access to anonymous users 124 124 125 125 {{{#!sh 126 trac-admin testpermission add anonymous TRAC_ADMIN126 $ trac-admin tracenv permission add anonymous TRAC_ADMIN 127 127 }}} 128 128 … … 132 132 133 133 {{{#!sh 134 svn co http://trac-hacks.org/svn/tracdeveloperplugin/trunk/ tracdeveloperplugin 135 cd tracdeveloperplugin 136 python setup.py bdist_egg 137 cp dist/*.egg ../test/plugins 138 cd .. 134 $ svn co http://trac-hacks.org/svn/tracdeveloperplugin/trunk/ tracdeveloperplugin 135 $ pip install tracdeveloperplugin 139 136 }}} 140 137 … … 142 139 143 140 {{{#!sh 144 tracd -r --port 8000 test 141 $ tracd -r -s --port 8000 tracenv 145 142 }}} 146 143 147 '''Note''': The `-r` command puts Trac into refresh mode so your code changes will show up quickly. See also the [TracIni#trac-section auto_reload] trac.ini flag, which should be used for the changes in Genshi templates to be picked-up as well.144 '''Note''': The `-r` command puts Trac into refresh mode so your code changes will immediately take effect. See also the [TracIni#trac-auto_reload-option auto_reload] option in trac.ini, which causes template changes to take effect immediately. 148 145 149 146 To run `tracd` or work in the virtual environment, you must switch to the virtual environment each time a new shell is opened: 150 147 {{{#!sh 151 cd test 152 sourcebin/activate148 $ cd /path/to/projects 149 $ source pve/bin/activate 153 150 }}} 154 151 155 === De bugging Plugins152 === Developing Plugins 156 153 157 To de bug a plugin, install it into your test environmentusing the command:154 To develop a plugin, checkout the source and install it in development mode using the command: 158 155 {{{#!sh 159 $ p ython setup.py develop -md /path/to/projenv/plugins156 $ pip install -e /path/to/plugin/src 160 157 }}} 161 158 162 If you are experiencing trouble s 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 of the checkedout sources.159 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. 163 160 164 161 === Open Trac in your browser 165 162 166 Switch to your browser and go to `http://127.0.0.1:8000/ test`163 Switch to your browser and go to `http://127.0.0.1:8000/` 167 164 168 165 Now do the following: … … 179 176 == Further guidelines 180 177 181 Check the [/roadmap milestones] pages to see if there are any specific requirements for the version you are setting up. Specifically, for Trac 0.12+, you need Genshi 0.6 or later. See milestone:0.12 for more information.178 Check the [/roadmap 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. 182 179 183 180 The (automated) tests will require additional packages that may or may not be installed with your OS/Python distribution.