Edgewall Software

Changes between Version 24 and Version 25 of TracDev/DevelopmentWithEclipseAndPyDev


Ignore:
Timestamp:
Jul 27, 2015, 9:09:44 PM (9 years ago)
Author:
figaro
Comment:

Cosmetic changes

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/DevelopmentWithEclipseAndPyDev

    v24 v25  
    1 [[PageOutline()]]
     1[[PageOutline(2-5,Contents,pullout)]]
    22
    3 = How to develop Trac with Eclipse !PyDev =
     3= How to develop Trac with Eclipse !PyDev
    44
    55Follow the instructions for ''Setting up the environment'' and ''Installing and configuring Trac'' on the [TracDev/DevelopmentEnvironmentSetup Developer setup for Trac] page, before configuring Eclipse and !PyDev.
    66
    7 == Installing and configuring Eclipse ==
     7== Installing and configuring Eclipse
    88
    99 1. Install [http://www.eclipse.org Eclipse] (3.3 or newer will do).
     
    1111 1. Alternatively, install [[http://brainwy.github.io/liclipse|LiClipse]], it comes with !PyDev already integrated.
    1212 1. (Optional) Install either [http://subclipse.tigris.org Subclipse] or [http://www.eclipse.org/subversive/ Subversive] for Eclipse-integrated Subversion tools.
    13  1. Create a new project in Eclipse that contains the sources for trac
    14  1. In Eclipse, make sure that the PYTHONPATH in the project properties dialog includes the sources for trac and for genshi.
    15  1. Create an initial run configuration by clicking right on ''trac/web/standalone.py file'', and choosing ''Run As->Python Run''. Trac will complain that no environment has been set.
    16  1. Select ''Run->Open Run Dialog...'' and set the correct command line arguments in the ''arguments'' tab, eg. ''--port 8000 /path/to/myproject''.
    17   * Note that the option --auto-reload will cause tracd to restart every time source code has been changed, but it seems to prevent debugging with !PyDev. This seems to have something to do way Trac reloads new instance as a child thread using "thread" library which doesn't seem to be compatible with !PyDev debugging. Googling revealed some hints that instead using "thread"-module you should use "threading"-module (higherlevel)
    18   * Note that if you debugging doesn't work with a plugin then remove the package from the install destination (eg. ''rm -Rf'') and soft link it from your source.
    19  1. You should now be able to run tracd, as well as to debug it using the same run configuration. To run the test cases, just click on a test folder and select ''Run->Python unit tests''.
     13 1. Create a new project in Eclipse that contains the sources for Trac.
     14 1. In Eclipse, make sure that the PYTHONPATH in the project properties dialog includes the sources for Trac and for Genshi.
     15 1. Create an initial run configuration by clicking right on ''trac/web/standalone.py file'', and choosing ''Run As -> Python Run''. Trac will complain that no environment has been set.
     16 1. Select ''Run -> Open Run Dialog...'' and set the correct command line arguments in the ''arguments'' tab, eg. ''--port 8000 /path/to/myproject''.
     17  * Note that the option --auto-reload will cause tracd to restart every time source code has been changed, but it seems to prevent debugging with !PyDev. This seems to have something to do with the way Trac reloads new instance as a child thread using "thread" library, which doesn't seem to be compatible with !PyDev debugging. Googling revealed some hints that instead using "thread"-module you should use "threading"-module (higherlevel).
     18  * Note that if your debugging doesn't work with a plugin, then remove the package from the install destination (eg. ''rm -Rf'') and soft link it from your source.
     19 1. You should now be able to run tracd, as well as to debug it using the same run configuration. To run the test cases, just click on a test folder and select ''Run -> Python unit tests''.
    2020
    21 == Automatic translation compilation ==
     21== Automatic translation compilation
    2222
    23 If you want to setup automatic translation compilation it can be done very easily.
     23If you want to setup automatic translation compilation do the following:
    2424
    25  1. Right click on trac project and select ''Properties''. Select ''Builders''. Click ''New''. Select ''Program''.
    26  1. Name builder, like 'Locale fi_FI builder'
     25 1. Right click on Trac project and select ''Properties''. Select ''Builders''. Click ''New''. Select ''Program''.
     26 1. Name builder, like 'Locale fi_FI builder'.
    2727 1. ''Main'' tab:
    2828  * ''Location'': click ''Browse File System...''. Select Python executable.
    29   * ''Working Directory'': set it to ''${project_loc}''
    30   * ''Arguments'': ''setup.py compile_catalog -f -l fi_FI'' (change to your locale)
     29  * ''Working Directory'': set it to ''${project_loc}''.
     30  * ''Arguments'': ''setup.py compile_catalog -f -l fi_FI'' (change to your locale).
    3131 1. ''Refresh'' tab:
    3232  * Check ''Refresh resources upon completion''.
    33   * Select ''Spesific resources'' and select ''trac/locale/fi_FI'' (select your locale)
     33  * Select ''Spesific resources'' and select ''trac/locale/fi_FI'' (select your locale).
    3434 1. ''Build Options'' tab:
    3535  * Check ''During auto builds''.
    36   * Check ''Specify working set of relevan resources''.[[BR]]
    37   * Click ''Specify resources...''. select ''trac/locale/fi_FI'' (select your locale, same as in step 4).
     36  * Check ''Specify working set of relevant resources''.
     37  * Click ''Specify resources...''. Select ''trac/locale/fi_FI'' (select your locale, same as in step 4).
    3838  *  Name it like ''fi_FI locale''.
    3939 1. After modifying your message.po file you should get following output:
     
    4949!PyLint is a validator and quality checker for the Python programming language. It can be integrated with !PyDev, see [http://pydev.org/manual_adv_pylint.html pydev.org] for details.
    5050
    51 For developing Trac plugins, you should reference to all dependend eggs (such as Tarc, Genshi, Babel, etc.). To do this open  `Project > Properties`, go to node `PyDev - PYTHONPATH` and click on `Add zip/jar/egg/` in tab `External Libraries`. Search for your `Trac-$VERSION-.egg` and do the same for all required libraries (Genshi, Babel).
     51For developing Trac plugins, you should reference to all dependent eggs (such as Tarc, Genshi, Babel, etc.). To do this open  `Project > Properties`, go to node `PyDev - PYTHONPATH` and click on `Add zip/jar/egg/` in tab `External Libraries`. Search for your `Trac-$VERSION-.egg` and do the same for all required libraries (Genshi, Babel).
    5252
    53 If you import from `pkg_resources` you need to add `#@UnresolvedImport` after it, because otherwise you get the error: `Unresolved import: resource_filename` (see [http://stackoverflow.com/questions/6336882/pylint-doesnt-like-pkg-resources-resource-filename stackoverflow-question] for details):
     53If you import from `pkg_resources` you need to add `#@UnresolvedImport` after it, because otherwise you get the error: `Unresolved import: resource_filename`. See [http://stackoverflow.com/questions/6336882/pylint-doesnt-like-pkg-resources-resource-filename stackoverflow-question] for details:
    5454
    5555{{{#!py
     
    5959== Ignoring warnings
    6060
    61 As described in [http://stackoverflow.com/a/14591913/995610 stackoverflow] you can use a "deactivation comment" at the end of the line, if you want to suppress a warning.
    62 
    63 Examples:
     61As described in [http://stackoverflow.com/a/14591913/995610 stackoverflow] you can use a "deactivation comment" at the end of the line, if you want to suppress a warning. Examples:
    6462{{{#!py
    6563from pkg_resources import resource_filename  # @UnresolvedImport
     
    7169== Format Code
    7270
    73 To enable Code Formatting using PEP8 (command "Format Code", short cut `Ctrl + Shift + F`) you need to check Preferences-> {{{PyDev/Editor/CodeStyle/CodeFormatter}}} and activate "Using autopep8.py for code formatting".
    74 
     71To enable Code Formatting using PEP8 (command "Format Code", short cut `Ctrl + Shift + F`) you need to check Preferences ->  {{{PyDev/Editor/CodeStyle/CodeFormatter}}} and activate "Using autopep8.py for code formatting".
    7572
    7673== Remote Debugging
     
    7976
    8077How to setup the remote debugger is described in [http://pydev.org/manual_adv_remote_debugger.html PyDev Manual]. Basically you need to follow these steps:
    81  1. Go to the debug perspective
    82  1. Start the remote debugger server
    83  1. Make sure `pydevd.py` is in your pythonpath: the python file usually resides under `eclipse/plugins/org.python.pydev_x.x.x/pysrc/pydevd.py`
     78 1. Go to the debug perspective.
     79 1. Start the remote debugger server.
     80 1. Make sure `pydevd.py` is in your pythonpath: the python file usually resides under `eclipse/plugins/org.python.pydev_x.x.x/pysrc/pydevd.py`.
    8481
    85 Then you can insert following code to start the debug mode (see [attachment:pydev_debug_screenshot.png Screenshot]):
     82Then you can insert the following code to start the debug mode (see [attachment:pydev_debug_screenshot.png Screenshot]):
    8683{{{#!py
    8784try: import pydevd;pydevd.settrace() #@UnresolvedImport
     
    8986}}}
    9087
    91 == Thanks ==
     88== Acknowledgements
    9289
    9390Originally these instructions were [http://groups.google.de/group/trac-dev/msg/235281558542b2ff posted on trac-dev list] by Joachim Hoessler.