Edgewall Software

Changes between Version 39 and Version 40 of TracDev/DevelopmentEnvironmentSetup


Ignore:
Timestamp:
Apr 26, 2017, 4:25:49 AM (7 years ago)
Author:
Ryan J Ollos
Comment:

Revise to use pip rather than setuptools.

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/DevelopmentEnvironmentSetup

    v39 v40  
    55== Installing the development tools
    66
    7 Before we begin to develop in Trac, or even download Trac code, create a standalone environment.
     7Before we begin to develop in Trac, or even download Trac code, we create a standalone Python environment.
    88
    99=== Create a working directory
    1010
    11 Create a projects or working directory for your development efforts. So for example on some systems, you might have:
     11Create a working directory for your development to take place in. For example, on Unix you might have:
    1212{{{
    13 /Users/myname/projects
     13/home/<user>/projects
    1414}}}
    1515
    16 On Windows you would have:
     16On Windows you might have:
    1717{{{
    1818C:\projects
     
    2323=== Get Subversion
    2424
    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 installation there.
     25This tutorial assumes you have Subversion (SVN) installed. If not, go to the [http://subversion.apache.org/ Subversion] website and follow the installation directions there.
    2626
    2727=== Get Python
    2828
    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):
     29On 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):
    3030{{{#!sh
    31 sudo apt-get install python2.6
     31$ sudo apt-get install python
    3232}}}
    3333
    3434You will also need some additional libraries:
    3535{{{#!sh
    36 sudo apt-get install python-subversion
     36$ sudo apt-get install python-subversion
    3737}}}
    3838
     
    4141 * The commercial [http://www.activestate.com/activepython/ ActivePython] from ActiveState.
    4242
    43 Mac OS X 10.5 and later has Python >= 2.5 pre-installed.
     43Mac 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].
    4444
    45 === Get easy_install
     45=== Get pip
    4646
    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:
     47You'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:
    5048{{{#!sh
    51 python ez_setup.py
     49$ pip --version
    5250}}}
    53 
    54 To test if the installation was successful:
    55 {{{#!sh
    56 easy_install --help
    57 }}}
     51Use [https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py get-pip.py] if you need to install `pip`.
    5852
    5953=== Get virtualenv
    6054
    61 From the command-line prompt type:
     55You may already have `virtualenv` installed.
    6256{{{#!sh
    63 python -m easy_install virtualenv
     57$ virtualenv --version
    6458}}}
    6559
    66 On Linux you may need to prepend `python` with `sudo`.
     60If you need to install `virtualenv`, or you wish to upgrade the package:
     61{{{#!sh
     62$ pip install -U virtualenv
     63}}}
     64
     65You may need to prefix the command with `sudo` on Unix platforms.
    6766
    6867=== Set up a virtual environment
     
    7069From the command-line prompt type:
    7170{{{#!sh
    72 virtualenv trac
    73 cd trac
    74 source bin/activate
     71$ virtualenv pve
     72$ source pve/bin/activate
    7573}}}
    7674
    7775or 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
    8279}}}
    83 
    84 If you have Trac installed in `/usr/lib` or `/usr/local/lib`, run the above virtualenv command with `--no-site-packages`.
    8580
    8681You'll see your command-line prompt has changed. That means your environment is ready for Trac.
    8782
    88 === Upgrade Setuptools
     83=== Upgrade Dependencies
    8984
    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]:
     85Upgrade the dependencies in your environment.
    9186{{{#!sh
    92 easy_install --upgrade setuptools
     87$ pip install -U pip setuptools wheel
    9388}}}
    9489
     
    10196=== Download Trac
    10297
    103 You should get the Trac source code from one of the TracRepositories. For example, for Subversion from the command-line prompt:
     98You should get the Trac source code from one of the TracRepositories. For example, to checkout from Subversion using the command-line:
    10499{{{#!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
    112102}}}
    113103
    114 === Create your test Trac environment
     104Install the packages in development mode:
     105{{{#!sh
     106$ pip install -e genshi-trunk
     107$ pip install -e trac-trunk
     108}}}
     109
     110For 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
    115117
    116118From the command-line prompt:
    117119{{{#!sh
    118 trac-admin test initenv
     120$ trac-admin tracenv initenv "TracDev" sqlite:db/trac.db
    119121}}}
    120 
    121 '''Note:''' Press return for every option.
    122122
    123123=== Grant full access to anonymous users
    124124
    125125{{{#!sh
    126 trac-admin test permission add anonymous TRAC_ADMIN
     126$ trac-admin tracenv permission add anonymous TRAC_ADMIN
    127127}}}
    128128
     
    132132
    133133{{{#!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
    139136}}}
    140137
     
    142139
    143140{{{#!sh
    144 tracd -r --port 8000 test
     141$ tracd -r -s --port 8000 tracenv
    145142}}}
    146143
    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.
    148145
    149146To run `tracd` or work in the virtual environment, you must switch to the virtual environment each time a new shell is opened:
    150147{{{#!sh
    151 cd test
    152 source bin/activate
     148$ cd /path/to/projects
     149$ source pve/bin/activate
    153150}}}
    154151
    155 === Debugging Plugins
     152=== Developing Plugins
    156153
    157 To debug a plugin, install it into your test environment using the command:
     154To develop a plugin, checkout the source and install it in development mode using the command:
    158155{{{#!sh
    159 $ python setup.py develop -md /path/to/projenv/plugins
     156$ pip install -e /path/to/plugin/src
    160157}}}
    161158
    162 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 of the checked out sources.
     159If 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.
    163160
    164161=== Open Trac in your browser
    165162
    166 Switch to your browser and go to `http://127.0.0.1:8000/test`
     163Switch to your browser and go to `http://127.0.0.1:8000/`
    167164
    168165Now do the following:
     
    179176== Further guidelines
    180177
    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.
     178Check 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.
    182179
    183180The (automated) tests will require additional packages that may or may not be installed with your OS/Python distribution.