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.
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.
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).
Installation is very straight forward:
- 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.
- Download and install the latest Eclipse SDK here: http://www.eclipse.org/downloads/. It is at 3.2.1 at the moment.
- Run Eclipse and go to Help ⇒ Software Updates ⇒ Find and Install….
- Select Search for new features to install and hit Next.
- Using button New Remote Site add following sites:
- PyDev update site: http://pydev.sf.net/updates/. The latest version is 1.2.4.
- Subclipse update site: http://subclipse.tigris.org/update_1.0.x. It is at 1.0.3 now.
- 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.
- 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.
- Click Finish button, and wait.
- You are done.
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.
- Download the latest Subversion binary.
- Download the latest TortoiseSVN client software.
- 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.
- Install Subversion (run .msi file).
- Install TortoiseSVN (run the installer). It will require to reboot.
- 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.
- Right-click on repo subfolder (see example above) and select TortoiseSVN/Create Repository here….
- It will ask you for type of repository.
- Select FSFS — everybody recommends this new type. Ignore BDB.
- 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.
- Try to connect to it using TortoiseSVN or RapidSVN and make sure it works. Use connection string like that: svn://yourserver/.
- Install SrvAny by copying it to a folder of your choice.
- Install new service for svnserve (I’ve included a .doc file with manual for SrvAny and InstSrv).
- 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.
- Run regedit and navigate to this key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\svnserve.
- Create subkey Parameters.
- Add Application string value with exact fully qualified path to svnserve, e.g., C:\Program Files\Subversion\bin\svnserve.exe.
- Add AppParameters string value with following data: -d -r C:\Repository\svn\repo. If you used different repository folder, change the value accordingly.
- Run the service using the standard Windows Services panel.
If you don’t want to keep your repository wide open, it is time to modify security settings.
- In subdirectory C:\Repository\svn\repo\conf create passwd (see below).
- Obviously you should use real user names and real passwords.
- In the same directory create (or modify) file svnserve.conf (see below).
- You can specify different file name for password-db and select different realm name. Realm is used to inform user about purpose of authentication.
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.
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.
- Download the latest Trac installer.
- Follow official instructions to download and install prerequisites. All deviations are outlined below:
- 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.
- 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.
- 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.
- 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.
Install new service for tracd.
- 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.
- Run regedit and navigate to this key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\tracd.
- Create subkey Parameters.
- Add Application string value with exact fully qualified path to python, e.g., C:\Python24\python.exe.
- 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.
- Run the service using the standard Windows Services panel.
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.
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.