Hello, reader!

My name is Eugene Lazutkin.

I'm a software developer based in the Dallas-Fort Worth metroplex. Lazutkin.com is my professional blog, which contains short writeups and presentations regarding modern web applications. All articles here are written by myself, unless stated otherwise.

Setting up tools on Windows

Update 9/30/2006: when you finish this article don’t forget to read more about setting up tools in the second part: Setting up tools 2.

My goal is to set up working environment for Django development on Windows box. You can find a lot of information on setting up open-source development tools on Linux. Somehow it is assumed that your project should target LAMP (Linux, Apache, MySQL, Python). Windows-bound guys are advised to decorate their platform as ersatz Linux: install Apache, install MySQL, and you have WAMP (Windows, Apache, MySQL, Python). What kind of fun is that? No, we are going full WIMP (Windows, IIS, MS SQL, Python)!

Below are my notes from July-August 2005 (Eclipse section was updated on 9/30/2006) on setting up a development environment on Windows XP/2003. Most probably you can apply them to Windows 2000 as well.

Python

Mother of all Python-related information is http://www.python.org/. It hosts Python documentation and interpreters for all platforms. Official Python.org document describes an installation of Python 2.4.2 in details. Basically you download an installer and just run it. That’s it.

Another option is ActiveState’s ActivePython. It is very nice. Let’s go with it.

Eclipse

This section was updated on 09/30/2006.

Eclipse is the most popular free IDE with open API. It is highly customizable and appropriately platform-neutral. Eclipse supports many languages via plugins. There are plugins for Python and Subversion (more on that later).

PyDev is very popular Eclipse plugin for Python. Another popular option is TruStudio Foundation, which is free open source version of TruStudio Professional. It provides PHP support as well. To integrate our project with source control system we will use Subclipse (you can find more information on Subversion below).

If you want to do some HTML/CSS editing and AJAX/JavaScript coding (I know you want to), please refer to Setting up tools 2 for instructions.

Installation is very straight forward:

  1. Download and install the latest Java JRE or JDK here: http://java.sun.com/javase/downloads/index.jsp. It is at 1.5.9 at the moment.
  2. Download and install the latest Eclipse SDK here: http://www.eclipse.org/downloads/. It is at 3.2.1 at the moment.
  3. Run Eclipse and go to Help ⇒ Software Updates ⇒ Find and Install….
  4. Select Search for new features to install and hit Next.
  5. Using button New Remote Site add following sites:
    1. PyDev update site: http://pydev.sf.net/updates/. The latest version is 1.2.4.
    2. Subclipse update site: http://subclipse.tigris.org/update_1.0.x. It is at 1.0.3 now.
      1. If you feel adventurous, you may try a beta version using following update site: http://subclipse.tigris.org/update_1.2.x. The current version is 1.1.6.
      2. At the moment of this writing it may clash with the latest TortoiseSVN 1.4.0, because it changed a repository format. Nothing serious, but it may be kind of annoying to get error messages in Eclipse. I am sure it will be fixed soon.
  6. Click Finish button, and wait.
  7. You are done.

Subversion (SVN)

It looks like Subversion is the most reasonable choice for source control:

  • It is free open source project available on virtually all platforms.
  • It was designed as replacement for aging CVS, which is the most dominant source control system for distributed open source projects.
  • It is well supported. After CVS it is the most mature and stable source control system.
  • It is possible to find hosts, which offer SVN hosting for free or commercially.
  • It looks like a preferred choice for new projects.
  • It is easy to host internally.

A must read is free electronic book available in HTML and PDF formats here: http://svnbook.org/. Links to documentation, examples, tools, and clients can be found here: http://subversion.tigris.org/project_links.html.

Subversion provides access to repository using either Apache (via http or https) or its own proprietary svn protocol. The latter method supports secure SSH variation: svn+ssh protocol. Apache integration includes WebDAV support and (optional and not recommended) FrontPage support.

While there are many Subversion clients around, two are the most popular choices for Windows platform:

I tried both of them and TortoiseSVN feels better for me. The caveat is it is integrated with Windows Explorer ⇒ pollutes right-click menu. RapidSVN is stand-alone program.

Let’s install Subversion with TortoiseSVN. Below are step by step instructions inspired by Miguel Jimenez’s excellent post on this subject: http://blogs.clearscreen.com/migs/archive/2005/01/21/824.aspx. Our goal is to run Subversion as a Windows service. In this case it may be placed on remote server and be available to all group members.

  1. Download the latest Subversion binary.
  2. Download the latest TortoiseSVN client software.
  3. Download the latest SrvAny utility (it’s a part of free Resource Kit, e.g. Windows Server 2003 Resource Kit Tools). Alternatively you can use my version extracted from the latest Resource Kit.
  4. Install Subversion (run .msi file).
  5. Install TortoiseSVN (run the installer). It will require to reboot.
  6. Create a folder for your repository (e.g., C:\Repository). Create svn subfolder in it to keep SVN data separate from Trac data later on (e.g., C:\Repository\svn). Create one more subfolder in svn to host actual database (e.g., C:\Repository\svn\repo). Actual names and actual layout are up to you.
  7. Right-click on repo subfolder (see example above) and select TortoiseSVN/Create Repository here….
    1. It will ask you for type of repository.
    2. Select FSFS — everybody recommends this new type. Ignore BDB.
    3. Now you can run svnserve (it is in bin directory of Subversion) to test your installation: svnserve -d -r C:\Repository\svn\repo. It uses TCP port 3690.
    4. Try to connect to it using TortoiseSVN or RapidSVN and make sure it works. Use connection string like that: svn://yourserver/.
  8. Install SrvAny by copying it to a folder of your choice.
  9. Install new service for svnserve (I’ve included a .doc file with manual for SrvAny and InstSrv).
    1. Run InstSrv with following arguments: InstSrv svnserve SrvAny.exe. You can use any name instead of svnserve here. Sometimes fully qualified name is required for SrvAny.exe.
    2. Run regedit and navigate to this key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\svnserve.
    3. Create subkey Parameters.
      1. Add Application string value with exact fully qualified path to svnserve, e.g., C:\Program Files\Subversion\bin\svnserve.exe.
      2. Add AppParameters string value with following data: -d -r C:\Repository\svn\repo. If you used different repository folder, change the value accordingly.
    4. Run the service using the standard Windows Services panel.
  10. If you don’t want to keep your repository wide open, it is time to modify security settings.
    1. In subdirectory C:\Repository\svn\repo\conf create passwd (see below).
    2. Obviously you should use real user names and real passwords.
    3. In the same directory create (or modify) file svnserve.conf (see below).
    4. You can specify different file name for password-db and select different realm name. Realm is used to inform user about purpose of authentication.
    5. Now use any SVN client to test connection to your new Subversion service.
[users]
user1 = password1
user2 = password2
[general]
anon-access = none
auth-access = write
password-db = passwd
realm = Subversion Repository

If you want to serve several repositories, you should create several services for that. Obviously you should specify different ports for different repositories.

Trac

While Subversion can integrate with Apache to provide simple browsing of HEAD, higher-level tools are available. The most popular tool is Trac, which supports project’s Wiki, roadmaps, tickets (todo lists), and tracks changes in Subversion’s repository. Trac can be used with Apache and with experimental stand-alone Python-based server.

I assume you installed Subversion server as I outlined above. You may read the official documentation on standalone Trac, which explains some details. Our goal is to run Trac as a Windows service.

  1. Download the latest Trac installer.
  2. Follow official instructions to download and install prerequisites. All deviations are outlined below:
    1. We are going to use Python 2.4 instead of Python 2.3. I never understood explanations why you cannot run Trac with Python 2.4 and mentioned my method publicly long time ago. One example is in comments of Simon Brunning’s blog. It is nice to see that it is included in the official Trac instructions now.
    2. Create trac subfolder in your main repository directory (e.g., C:\Repository\trac). Create one more subfolder in trac to host actual database (e.g., C:\Repository\trac\repo). Actual names and actual layout are up to you.
    3. Skip Apache parts completely — we are going to use tracd. You will need one Apache utility: htdigest. It is used to prepare htdigest file for authentication. Create it in the root of your repository, e.g., C:\Repository\trac_passwd. See htdigest documentation for details.
  3. Using any hex editor patch following files (use your actual Python path) by replacing all references to “python23” with “python24” (or download already patched copies). The list of replacements can be found below.
  4. Install new service for tracd.
    1. Run InstSrv with following arguments: InstSrv tracd SrvAny.exe. You can use any name instead of tracd here. Sometimes fully qualified name is required for SrvAny.exe.
    2. Run regedit and navigate to this key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\tracd.
    3. Create subkey Parameters.
      1. Add Application string value with exact fully qualified path to python, e.g., C:\Python24\python.exe.
      2. Add AppParameters string value with following data: C:\Python24\Scripts\tracd -p 8080 -a repo,C:\Repository\trac_passwd,SVN C:\Repository\trac\repo. If you used different repository folder, change values accordingly. Make sure that full path to tracd is specified. Note that it is configured to run on 8080 TCP port.
    4. Run the service using the standard Windows Services panel.
    5. Test it with your browser.
C:\Python24\Lib\libsvn\_core.dll
C:\Python24\Lib\libsvn\_delta.dll
C:\Python24\Lib\libsvn\_fs.dll
C:\Python24\Lib\libsvn\_ra.dll
C:\Python24\Lib\libsvn\_repos.dll
C:\Python24\Lib\libsvn\_wc.dll
C:\Python24\Lib\libsvn\_client.dll

More information on tracd and some Windows-specific notes can be found here: http://projects.edgewall.com/trac/wiki/TracStandalone.

Next

What’s next? In my crystal ball I see using Django with MS SQL, and running it on IIS. I will definitly try to run Django with IronPython.