Differences between revisions 3 and 5 (spanning 2 versions)
Revision 3 as of 2008-07-31 05:33:54
Size: 1757
Editor: khelben
Comment:
Revision 5 as of 2008-07-31 08:01:20
Size: 6104
Editor: khelben
Comment:
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
~-Written by a newbie, for newbies.-~[[BR]]
~-Versions specified are the versions used when writing this tutorial and may not reflect current versions available.-~
Line 6: Line 8:

Special thanks to djc for all the help in IRC.
Line 19: Line 23:
Extract c:\wamp\mercurial\library.zip to C:\wamp\mercurial\lib '''1.''' Install WAMP if not already installed.
 * Your installation directory will be referred to as ```<WAMPPath>```
 * Be sure to enable mod_rewrite.
Line 21: Line 27:
Create 'hg' dir in c:\wamp\www '''2.''' Install Python 2.5 if not installed.
 * Your installation directory will be referred to as ```<PythonPath>```
Line 23: Line 30:
Download [http://svn.aminus.net/misc/modpython_gateway.py modpython_gateway.py] and install to <Python Path>Lib\site-packages '''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```[[BR]][[BR]]
 * 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```
Line 25: Line 36:
Download [http://www.selenic.com/repo/hg-stable/raw-file/tip/hgwebdir.cgi hgwebdir.cgi] and place in c:\wamp\mercurial\ (One doesn't come in the binary package unless I missed it) '''4.''' Install Python Win32 API
Line 27: Line 38:
Rename hgwebdir.cgi to hgwebdir.py '''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, so keep that in mind when choosing your installation home. (I chose to install to (D:) because it's raided and has more space)
 * Your install path will be ```<MercurialPath>```
Line 29: Line 43:
Edit hgwebdir.py to the following: '''6.''' Extract ```<MercurialPath>```\library.zip to ```<MercurialPath>```\lib
Line 31: Line 45:
  ...blah... '''7.''' Create 'hg' dir in ```<WAMPPath>```\www
Line 33: Line 47:
'''8.''' Download [http://svn.aminus.net/misc/modpython_gateway.py modpython_gateway.py] and install to <Python Path>\Lib\site-packages
Line 34: Line 49:
Create c:\wamp\alias\hg.conf with the following contents: '''9.''' Download [http://www.selenic.com/repo/hg-stable/raw-file/tip/hgwebdir.cgi 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''''':
Line 36: Line 53:
<Location /hg> '''hgwebdir.py'''
Line 38: Line 55:
  PythonPath "sys.path + [ 'c:\\wamp\\mercurial' ]" {{{
#!<PythonPath>\python.exe
#
# An example Python script to export multiple hgweb repos, edit as necessary
Line 40: Line 60:
# Add a python path if mercurial is not a system-wide install:
#import sys
#sys.path.insert(0, "<MercurialPath>\lib")

# May be required to change Python Working path to support collections
#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

'''hg.conf'''
{{{<Location /hg>
  PythonPath "sys.path + [ '<MercurialPath>' ]"
Line 41: Line 117:
  SetHandler mod_python
  PythonHandler modpython_gateway::handler
  PythonOption SCRIPT_NAME /hg
  PythonOption wsgi.application hgwebdir::application
</Location>}}}
Line 42: Line 123:
  SetHandler mod_python '''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.
Line 44: Line 131:
  PythonHandler modpython_gateway::handler 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).
Line 46: Line 133:
  PythonOption SCRIPT_NAME /hg '''hgweb.conf'''
{{{[collections]
repos\ = repos/}}}
Line 48: Line 137:
  PythonOption wsgi.application hgwebdir::application

</Location>


Restart Apache
'''12.''' Restart Apache

WAMP Installation notes

Binaries and requirements used in setup:

Written by a newbie, for newbies.BR 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.

[http://wampserver.com/en/ WAMP 2.0c]

[http://www.python.org/ Python 2.5.2 (32 bit)]

[http://apache.ziply.com/httpd/modpython/win/3.3.1/ mod_python v3.3.1 (win32) (py2.5) (Apache2.2)]

[http://sourceforge.net/project/showfiles.php?group_id=78018&package_id=79063 Python Win32 API (py2.5)]

[http://www.selenic.com/mercurial/wiki/index.cgi/BinaryPackages Mercurial v1.01]

Installation Steps

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.8BRBR

  • 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, so keep that in mind when choosing your installation home. (I chose to install to (D:) because it's raided and has more space)

  • Your install path will be <MercurialPath>

6. Extract <MercurialPath>\library.zip to <MercurialPath>\lib

7. Create 'hg' dir in <WAMPPath>\www

8. Download [http://svn.aminus.net/misc/modpython_gateway.py modpython_gateway.py] and install to <Python Path>\Lib\site-packages

9. Download [http://www.selenic.com/repo/hg-stable/raw-file/tip/hgwebdir.cgi 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:

hgwebdir.py

#
# 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")

# May be required to change Python Working path to support collections
#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

hg.conf {{{<Location /hg>

</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).

hgweb.conf {{{[collections] repos\ = repos/}}}

12. Restart Apache

References:

http://www.selenic.com/mercurial/wiki/index.cgi/HgWebDirStepByStep

http://slucas.wikidot.com/en:hgweb-mod-python

http://www.modpython.org/FAQ/faqw.py?req=show&file=faq03.029.htp

Caveats:

Some errors will appear in appache error log, they can be ignored:

  • ..Errors...

WAMPInstall (last edited 2012-11-11 11:37:41 by abuehl)