1 | | = Development = |
2 | | |
3 | | === [wiki:Development Developing SasView with Eclipse] === |
| 1 | = DEVELOPING SASVIEW WITH ECLIPSE = |
| 2 | |
| 3 | Steve King, March 2014, Rev 6.1 |
| 4 | |
| 5 | == Installation & Setup == |
| 6 | Download & install the Eclipse SDK (eg, eclipse-SDK-4.3.2-win32) to a folder of your choice |
| 7 | Eclipse name their versions: |
| 8 | |
| 9 | 4.3.1:: Ganymede |
| 10 | 4.3.2:: Kepler |
| 11 | 4.4:: Luna |
| 12 | |
| 13 | Do not install a version of Eclipse earlier than 4.3.1 |
| 14 | Note that there are some subtle variations in the menu trees between versions! Most of this |
| 15 | document was originally written whilst using Ganymede. |
| 16 | |
| 17 | === Setting Proxy === |
| 18 | If your internet access is normally via a proxy server, locate and edit your |
| 19 | C:\Users\userid\AppData\Roaming\Subversion\servers file and add under the [global] section: |
| 20 | {{{ |
| 21 | http-proxy-host = site_proxy_server_address |
| 22 | http-proxy-port = site_proxy_server_port |
| 23 | }}} |
| 24 | |
| 25 | To see if you use a proxy server, and to get it’s address, open Internet Explorer, then go Tools |
| 26 | -> Internet Options -> Connections -> LAN Settings and look to see if you are using an |
| 27 | automatic configuration script. If so it will probably be configured to use port 8080. If in |
| 28 | doubt, contact your IT Support. |
| 29 | |
| 30 | === Installing PyDev === |
| 31 | Start Eclipse and open: File -> Switch Workspace -> Other... -> Select a workspace (the default is drive:\path\Eclipse_workspace) |
| 32 | |
| 33 | Window -> Open Perspective -> Other -> PyDev |
| 34 | |
| 35 | If PyDev is not listed as a perspective it will be necessary to install it: |
| 36 | |
| 37 | Help -> Install New Software... and in the Work With: drop-down select the PyDev Update Site. Let the list of available software refresh. |
| 38 | |
| 39 | Check the box next to PyDev and click Next. The plug-in will install. |
| 40 | |
| 41 | If this doesn’t work: |
| 42 | |
| 43 | Download the PyDev certificate from http://pydev.org/pydev_certificate.cer and install it (in |
| 44 | Windows, just right-click and select Install certificate) |
| 45 | |
| 46 | Now get PyDev from http://sourceforge.net/projects/pydev/files/ |
| 47 | If you have Java 7 installed, you must install PyDev 3.4.1 or later. |
| 48 | Extract the zip file to the Eclipse dropins folder and re-start Eclipse |
| 49 | |
| 50 | |
| 51 | === Installing Subversive === |
| 52 | For SVN access it is necessary for Eclipse to have the Subversive plug-in installed. Earlier versions of Eclipse |
| 53 | (e.g. 4.3.1) seemingly incorporated an SVN plug-in in the default distribution. Later versions (e.g. |
| 54 | Kepler) do not! |
| 55 | |
| 56 | To install Subversive: |
| 57 | |
| 58 | * (Help -> Install New Software... and in the Work With drop-down select the site for the Eclipse |
| 59 | release you are using. Let the list of available software refresh. |
| 60 | * Scroll down the list of available software and locate Subversive SVN Team Provider Sources (or similar). Check the box next to it and click Next. The plug-in will install. |
| 61 | * Restart Eclipse. |
| 62 | |
| 63 | * Window -> Preferences -> Team -> SVN -> SVN Connector |
| 64 | |
| 65 | * Check the drop-down. If present, select JavaHL (for Windows x86). If this is not present it will be necessary to install the connector. |
| 66 | |
| 67 | To install the Subversive Connector: |
| 68 | |
| 69 | * Help -> Install New Software |
| 70 | |
| 71 | * Alongside the Work With drop-down, click Add and enter a URL in the Location box, e.g: http://community.polarion.com/projects/subversive/download/eclipse/3.0/kepler-site/ (or visit http://www.polarion.com/products/svn/subversive/download.php for links to earlier versions of Subversive for Eclipse) |
| 72 | |
| 73 | * Let the list of available software refresh. |
| 74 | |
| 75 | * Scroll down the list of available software and locate a JavaHL Binaries plug-in appropriate to your OS. Check the box next to it and click Next. The plug-in will install. |
| 76 | |
| 77 | * Restart Eclipse. |
| 78 | |
| 79 | === Checking out Sasview Trunk === |
| 80 | File -> Import -> SVN -> Checkout Projects from SVN -> Next |
| 81 | |
| 82 | IF no_SVN_repository_shown: |
| 83 | Check ‘Create a new repository location’ -> Next -> Enter a URL for a SVN repository -> Next |
| 84 | |
| 85 | If Eclipse fails to download the trunk, try repeating the import process but this time using an |
| 86 | existing repository (see below). |
| 87 | |
| 88 | ELSE: |
| 89 | Check ‘Use existing repository location’ -> Select a SVN repository from the list shown -> Next |
| 90 | |
| 91 | The SasView SVN repository is hosted by SourceForge at: https://svn.code.sf.net/p/sasview/code |
| 92 | |
| 93 | For commit access aspiring developers need (read-only checkout is public): |
| 94 | a. to be registered with Source Forge, and |
| 95 | b. authorised by Paul Butler |
| 96 | |
| 97 | Eclipse will attempt to download the trunk. In the process it may be necessary to enter your SourceForge login details several times (because you are required to authenticate at each level of the repository) so check the ‘Save details’ box to speed up the authentication process. |
| 98 | |
| 99 | Enter a Workspace Location |
| 100 | |
| 101 | This can be any name you like, but will be the name given to your local trunk, and the name of the |
| 102 | folder it is stored in; ie, drive:\path\Eclipse_workspace\workspace_location |
| 103 | |
| 104 | If you want you can also give this location a custom label. |
| 105 | Do not change any of the other default settings on this dialog box! |
| 106 | |
| 107 | Click OK |
| 108 | |
| 109 | == Preparing to Build SasView == |
| 110 | |
| 111 | NB: THIS MAY NOT WORK PROPERLY IF YOU ARE BEHIND A FIREWALL BECAUSE THE BUILD MAKES |
| 112 | USE OF PYTHON EASY_INSTALL WHICH DYNAMICALLY DOWNLOADS PACKAGES FROM THE WEB |
| 113 | |
| 114 | === Installing Python === |
| 115 | The official version of Python for building SasView is 2.7 |
| 116 | |
| 117 | Install NumPy, SciPy, and the additional Python site packages for building SasView |
| 118 | |
| 119 | NB: if you are using a Win64 version of Python ensure you also download and install a Win64 |
| 120 | version of wxPython compatible with your Python 2.x installation! |
| 121 | |
| 122 | Install the other additional packages for building SasView |
| 123 | |
| 124 | Install MINGW |
| 125 | |
| 126 | In Windows Explorer: |
| 127 | Navigate to drive:\path\Python2x\lib\site-packages and delete any existing sasview .egg file |
| 128 | |
| 129 | Back in Eclipse: |
| 130 | Window -> Preferences -> General -> Editors -> Text Editors |
| 131 | |
| 132 | Check ‘Insert spaces for tabs’ |
| 133 | |
| 134 | Check ‘Show print margin’ and set the ‘Print margin column’ to 80 |
| 135 | |
| 136 | Check ‘Show line numbers’ |
| 137 | |
| 138 | Click OK |
| 139 | |
| 140 | Window -> Preferences -> PyDev -> Interpreter – Python |
| 141 | |
| 142 | If no Python interpreter is shown, click ‘New...’, enter a name for your Python installation and |
| 143 | ‘Browse...’ to its python.exe file |
| 144 | |
| 145 | Click OK |
| 146 | |
| 147 | In the PyDev Package Explorer pane: |
| 148 | |
| 149 | Navigate to the sansview folder within the trunk |
| 150 | |
| 151 | Right-click on sansview.py Run As Python Run |
| 152 | |
| 153 | If this fails with an error message in the console pane it means that there is no existing SasView build |
| 154 | – which is what you want! If, on the other hand, SasView starts up, search for a sasview .egg file! |
| 155 | |
| 156 | Then repeat this test. |
| 157 | |
| 158 | Locate setup.py in the top level of the trunk |
| 159 | |
| 160 | Right-click on run.py Properties Run/Debug Settings |
| 161 | |
| 162 | IF no_launch_configuration shown: |
| 163 | New -> Enter a name for the launch configuration |
| 164 | |
| 165 | Select the ‘Main’ tab -> Under ‘Project’, browse to the name of your trunk |
| 166 | |
| 167 | Select the ‘Arguments’ tab -> Type ‘install’ (without the quotes) in the box marked ‘Program arguments’ |
| 168 | |
| 169 | Click OK |
| 170 | |
| 171 | === Building SasView the First Time === |
| 172 | |
| 173 | Right-click on setup.py -> Run As -> Run Configurations... |
| 174 | |
| 175 | Or highlight your_trunk_project setup.py and then choose Run -> Run As -> Python Run |
| 176 | |
| 177 | SasView should build from your local trunk. If the build fails it will most likely be because a Python |
| 178 | package has not installed, in which case install it manually (eg, using easy_install) |
| 179 | |
| 180 | If you get an error about msvcr90.dll or msvcr90d.dll not being found, copy these from the Visual C++ |
| 181 | Redistributable installation (if present) or from a reputable website and put in your MinGW/bin |
| 182 | folder. |
| 183 | |
| 184 | === Re-building SasView after Development === |
| 185 | |
| 186 | Navigate to the setup.py within the trunk |
| 187 | |
| 188 | Right-click on setup.py -> Run As -> Python Run |
| 189 | |
| 190 | SasView should build! |
| 191 | |
| 192 | The locally-built version of SasView should appear in |
| 193 | drive:\path\Eclipse_workspace\workspace_location\dist as something similar to |
| 194 | sasview-3.0.0_r0-py2.7-win32.egg |
| 195 | |
| 196 | === Running SasView from Eclipse === |
| 197 | |
| 198 | Navigate to the run.py within the trunk |
| 199 | |
| 200 | Right-click on run.py -> Run As -> Python Run |
| 201 | |
| 202 | SasView should start up! |
| 203 | |
| 204 | NB: This is running SasView from compiling and building the Python/C/C++, it is not installing |
| 205 | SasView |
| 206 | |
| 207 | NB: If you run SasView at this point it may stop an Installer application from building, so if you want |
| 208 | an Installer application, create that first (see below)! |
| 209 | |
| 210 | === Creating a SasView Installer Package === |
| 211 | NB: You would not normally need to do this because that is the function of the Build Server! |
| 212 | Navigate to the sansview folder within the trunk |
| 213 | |
| 214 | Right-click on setup_exe.py Run As Python Run |
| 215 | |
| 216 | This should create a file SasView.exe in the sansview\dist folder of the trunk |
| 217 | |
| 218 | Double-click on installer.iss to bring up the Inno Setup Compiler |
| 219 | |
| 220 | Click the green ‘play’ button to build a SasView installer |
| 221 | |
| 222 | This should create a file setupSasView.exe in the sansview\Output folder of the trunk |
| 223 | |
| 224 | === Running Unit Tests === |
| 225 | |
| 226 | Locate an appropriate unit test in your_trunk_project\module\test |
| 227 | |
| 228 | Right-click on the utest_test-name.py file -> Run As -> Python unit-test |
| 229 | |
| 230 | NB: unit tests operate on the last built version of SasView, so if you have modified any modules or |
| 231 | unit tests you must re-build SasView first! |
| 232 | |
| 233 | The unit test your_trunk_project\test\utest_sansview.py executes all the unit tests |
| 234 | |
| 235 | NB: you must have previously installed unittest_xml_reporting (eg, easy_install |
| 236 | unittest_xml_reporting) |
| 237 | |
| 238 | Also see the section on ‘Checking the Build Server Tests’ below |
| 239 | |
| 240 | === Committing Code Changes to the SVN Server === |
| 241 | NB: run appropriate unit tests first! |
| 242 | |
| 243 | Save your changes to file.py |
| 244 | |
| 245 | Right-click on file.py -> Team -> Update (just in case someone has done something to the same file!) |
| 246 | |
| 247 | Right-click on file.py -> Team -> Commit |
| 248 | |
| 249 | Add a comment to describe your changes |
| 250 | |
| 251 | ==== To See/Compare Code Changes ==== |
| 252 | Either: |
| 253 | |
| 254 | Right-click on file.py Compare with Revision... / Local History... |
| 255 | |
| 256 | Or: |
| 257 | |
| 258 | Go to Source Forge |
| 259 | |
| 260 | Login |
| 261 | |
| 262 | Projects SasView Code |
| 263 | |
| 264 | NB: if you haven’t been coding for a while, right-click on the top level of the trunk and do Team -> Update |
| 265 | |
| 266 | === To Tidy Up the Trunk === |
| 267 | |
| 268 | Right-click on the top level of the trunk |
| 269 | |
| 270 | Team -> Cleanup |
| 271 | |
| 272 | |
| 273 | === Checking the Build Server Tests === |
| 274 | |
| 275 | The Build Server automatically runs the unit tests as part of the build process, and reports the |
| 276 | success/failure |
| 277 | |
| 278 | See, for example: |
| 279 | http://build.sasview.org/job/SasView_Ubuntu12.04_Py2.7/ |
| 280 | |
| 281 | If a build has failed unit tests the ‘ball’ will be red |
| 282 | |
| 283 | Click on the date/time string next to the ball to get a view of what changes were committed to that |
| 284 | build and what tests failed |
| 285 | |
| 286 | Click on a failed test link to see more detail about why a test failed |
| 287 | |
| 288 | === Branches === |
| 289 | Long-term code development projects, or modifications carrying a significant risk of breaking the |
| 290 | code, should not be committed to the trunk, but conducted in a branch of the trunk instead |
| 291 | Note that a branch is not simply a sub-folder of trunk |
| 292 | The top-level of the SasView code repository contains: |
| 293 | Web:: the sasview.org web pages |
| 294 | Trunk:: the code in the current development build |
| 295 | Releases:: the code in the current official release build |
| 296 | Branches:: copies of trunk being used for special development projects |
| 297 | |
| 298 | Only when branches are debugged, working and tested should they be merged back into the trunk. |
| 299 | |
| 300 | NB: developers using branches should be aware that their branch copy of trunk will naturally fall |
| 301 | behind the current trunk and should therefore periodically update their branch copy of trunk |
| 302 | |
| 303 | To create a branch in Eclipse: |
| 304 | |
| 305 | * Right-click on your_trunk_project -> Team -> Branch/Tag |
| 306 | * Modify the URL shown by adding /branches/name_of_branch |
| 307 | * Click Next |
| 308 | * Select the HEAD Revision |
| 309 | * Click OK |
| 310 | |
| 311 | To check if a branch has been created/exists: |
| 312 | * Switch to SVN view (top right corner of the Eclipse screen) |
| 313 | |
| 314 | To work with a different branch: |
| 315 | * In PyDev view, right-click on the top-level of the current trunk -> Team -> Switch to another |
| 316 | * Branch/Tag/Revision... |
| 317 | * Modify the URL shown to point to the appropriate branch |
| 318 | * Click OK |