Fixed code regions, which might save the author some time. :-)
|Deletions are marked like this.||Additions are marked like this.|
|Line 40:||Line 40:|
|* You should know that due to limitations of Python's ConfigParser class, repositories on Windows have a tough time with drive letters. Keep that in mind when choosing your installation home. (I chose to install to (D:) because it's raided and has more space on my system)||* You should know that due to limitations of Python's !ConfigParser class, repositories on Windows have a tough time with drive letters. Keep that in mind when choosing your installation home. (I chose to install to (D:) because it's raided and has more space on my system)|
WAMP Installation notes
Binaries and requirements used in setup:
Written by a newbie, for newbies.
Versions specified are the versions used when writing this tutorial and may not reflect current versions available.
INCOMPLETE - Need to finish.
Special thanks to djc for all the help in IRC.
mod_python v3.3.1 (win32) (py2.5) (Apache2.2)
1. Install WAMP if not already installed.
Your installation directory will be referred to as <WAMPPath>
- Be sure to enable mod_rewrite.
2. Install Python 2.5 if not installed.
Your installation directory will be referred to as <PythonPath>
3. Install mod_python.
When installing mod_python you will be asked for your Apache directory. This will depend on the version of apache you are using, in 2.0c it is 2.2.8 so in this example it is: <WAMPPath>\bin\apache\apache2.2.8
- Additionally you will need to add the appropriate line to httpd.conf to add the module. This can easily be done by clicking the WAMP system tray, going to the Apache folder, and clicking httpd.conf.
Search for LoadModule proxy_http_module modules/mod_proxy_http.so and add the following line afterward: LoadModule python_mod modules/mod_python.so
4. Install Python Win32 API
5. Install Mercurial Binaries
- I suggest installing Mercurial to the location where you are going to house your repository(ies)
You should know that due to limitations of Python's ConfigParser class, repositories on Windows have a tough time with drive letters. Keep that in mind when choosing your installation home. (I chose to install to (D:) because it's raided and has more space on my system)
Your install path will be <MercurialPath>
6. Extract <MercurialPath>\library.zip to <MercurialPath>\lib
7. Create 'hg' dir in <WAMPPath>\www
8. Download modpython_gateway.py and install to <Python Path>\Lib\site-packages
9. Download hgwebdir.cgi and place in <MercurialPath> (One doesn't come in the binary package unless I missed it)
- Rename hgwebdir.cgi to hgwebdir.py
Edit hgwebdir.py to the following replacing any previously defined path variable with their fully qualified paths:
#!<PythonPath>\python.exe # # An example Python script to export multiple hgweb repos, edit as necessary # Add a python path if mercurial is not a system-wide install: #import sys #sys.path.insert(0, "<MercurialPath>\lib") # Changes Python Working path to support collections in windows with mod_python #import os #os.chdir("<MercurialPath>") # enable importing on demand to reduce startup time from mercurial import demandimport; demandimport.enable() # Uncomment to send python tracebacks to the browser if an error occurs: #import cgitb #cgitb.enable() # If you'd like to serve pages with UTF-8 instead of your default # locale charset, you can do so by uncommenting the following lines. # Note that this will cause your .hgrc files to be interpreted in # UTF-8 and all your repo files to be displayed using UTF-8. # #import os #os.environ["HGENCODING"] = "UTF-8" from mercurial.hgweb.hgwebdir_mod import hgwebdir #import mercurial.hgweb.wsgicgi as wsgicgi # The config file looks like this. You can have paths to individual # repos, collections of repos in a directory tree, or both. # # [paths] # virtual/path = /real/path # virtual/path = /real/path # # [collections] # /prefix/to/strip/off = /root/of/tree/full/of/repos # # collections example: say directory tree /foo contains repos /foo/bar, # /foo/quux/baz. Give this config section: # [collections] # /foo = /foo # Then repos will list as bar and quux/baz. # # Alternatively you can pass a list of ('virtual/path', '/real/path') tuples # or use a dictionary with entries like 'virtual/path': '/real/path' application = hgwebdir('hgweb.config') #wsgicgi.launch(application)
10. Create <WAMPPath>\alias\hg.conf with the following contents:
Be sure to replace <MercurialPath> with the proper value (i.e. D:\Mercurial)
- Don't forget the single quotes
<Location /hg> PythonPath "sys.path + [ '<MercurialPath>' ]" #PythonDebug On #Uncomment this line if you got a problem and need debug information SetHandler mod_python PythonHandler modpython_gateway::handler PythonOption SCRIPT_NAME /hg PythonOption wsgi.application hgwebdir::application </Location>
11. Create <MercurialPath>\hgweb.conf
- This file will be your config file for HGWEBDIR.
It must contain the RELATIVE path to your repositories from your Python Working Directory.
The path structure is WINDOWS_FORMAT\ = UNIX_FORMAT/ the slash direction is VERY IMPORTANT!
- If hgweb.conf is incorrectly configured you may experience the following:
- %5C URL Errors.
- No repositories displayed.
Here is an example for a configuration containing collections in a directory called 'repos' which is a subdirectory of my Mercurial install (Which I set to be my Python Working Directory in hgwebdir.py).
[collections] repos\ = repos/
12. Restart Apache
# Add a python path if mercurial is not a system-wide install: #import sys #sys.path.insert(0, "<MercurialPath>\lib")
Uncommenting the last 2 lines here will add another path that Python will search.
Necessary for this install.
Not necessary if you compiled from source and did a global install.
# Changes Python Working path to support collections in windows with mod_python #import os #os.chdir("<MercurialPath>")
Uncommenting the last two lines here will forcibly change the Python working directory.
This is probably necessary for any Mercurial install on windows that uses mod_python, unless your repositories are located in a sub dir of <PythonPath>\Lib\site-installs which I don't think anyone in their right mind would do.
Make sure this is commented out or deleted, in the raw file it is not and will error you out.
Some errors will appear in appache error log, they can be ignored: