Changes between Version 24 and Version 25 of TracDev/DevelopmentWithEclipseAndPyDev
- Timestamp:
- Jul 27, 2015, 9:09:44 PM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracDev/DevelopmentWithEclipseAndPyDev
v24 v25 1 [[PageOutline( )]]1 [[PageOutline(2-5,Contents,pullout)]] 2 2 3 = How to develop Trac with Eclipse !PyDev =3 = How to develop Trac with Eclipse !PyDev 4 4 5 5 Follow 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. 6 6 7 == Installing and configuring Eclipse ==7 == Installing and configuring Eclipse 8 8 9 9 1. Install [http://www.eclipse.org Eclipse] (3.3 or newer will do). … … 11 11 1. Alternatively, install [[http://brainwy.github.io/liclipse|LiClipse]], it comes with !PyDev already integrated. 12 12 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 trac14 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 w ay 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 pluginthen 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''. 20 20 21 == Automatic translation compilation ==21 == Automatic translation compilation 22 22 23 If you want to setup automatic translation compilation it can be done very easily.23 If you want to setup automatic translation compilation do the following: 24 24 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'. 27 27 1. ''Main'' tab: 28 28 * ''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). 31 31 1. ''Refresh'' tab: 32 32 * 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). 34 34 1. ''Build Options'' tab: 35 35 * 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). 38 38 * Name it like ''fi_FI locale''. 39 39 1. After modifying your message.po file you should get following output: … … 49 49 !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. 50 50 51 For developing Trac plugins, you should reference to all dependen deggs (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).51 For 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). 52 52 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):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: 54 54 55 55 {{{#!py … … 59 59 == Ignoring warnings 60 60 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: 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. Examples: 64 62 {{{#!py 65 63 from pkg_resources import resource_filename # @UnresolvedImport … … 71 69 == Format Code 72 70 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 71 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". 75 72 76 73 == Remote Debugging … … 79 76 80 77 How 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`. 84 81 85 Then you can insert following code to start the debug mode (see [attachment:pydev_debug_screenshot.png Screenshot]):82 Then you can insert the following code to start the debug mode (see [attachment:pydev_debug_screenshot.png Screenshot]): 86 83 {{{#!py 87 84 try: import pydevd;pydevd.settrace() #@UnresolvedImport … … 89 86 }}} 90 87 91 == Thanks ==88 == Acknowledgements 92 89 93 90 Originally these instructions were [http://groups.google.de/group/trac-dev/msg/235281558542b2ff posted on trac-dev list] by Joachim Hoessler.