#1 By: WarrenP, June 25th, 2012 09:51
Bitnami Trac Stack is installed on a Win2008R2 box.
I would like to install the mercurial plugin as shown here called TracMercurial.
I follow the instructions to download and build an
.egg and get that put into the Trac installation, and if I get the right version (0.12) instead of the wrong one, it works.
I have the right .egg installed.
These are the changes I think I need in trac.ini
tracext.hg.* = enabled
repository_type = hg
show_rev = yes
node_format = short
Anyways, no errors in the log but when I look at the Admin page, I still don't see a Mercurial repository option when adding a repository.
What my situation seems to be is that I have the basic Plugin as an .Egg but not one or more dependencies, such as perhaps an .egg file containing Mercurial itself, within the Python2.6 bitnami track stack.
Can I get the mercurial plugin working in trac? (Boy it would be nice to have this added to the Trac Stack, is there a wishlist area I can add this request to?.)
I tried an
Easy_Install mercurial command, from the bitnami command prompt. It won't complete due to the error that it can't find vcvarsall.bat, which I have and which is in the path, but might be the wrong version of Visual Studio (2010 instead of 2008 maybe?).
So maybe a great future idea would be to add Mercurial itself, to a bitnami stack, and both mercurial, and the TracMercurial plugin to the Trac stack.
At first, I'm getting this error in the main page of Trac when it opens:
(Unsupported version control system "hg": No module named mercurial)
Then, I get mercurial modules put into Python 2.6, and I get this error:
(Unsupported version control system "hg": DLL load failed:
The specified module could not be found.).
In both cases, it says
Look in the Trac log for more information. -- the error message here seems to be the problem:
Traceback (most recent call last):
File "build\\bdist.win32\\egg\\trac\\loader.py", line 68, in _load_eggs
File "build/bdist.linux-i686/egg/pkg_resources.py", line 1954, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "C:\\Program Files\\BitNami Trac Stack\\python\\lib\\site-packages\\mercurial\\demandimport.py", line 114, in _demandimport
mod = _origimport(name, globals, locals)
File "build\\bdist.win32\\egg\\trac\\mimeview\\rst.py", line 155, in <module>
File "C:\\Program Files\\BitNami Trac Stack\\python\\lib\\site-packages\\mercurial\\demandimport.py", line 87, in __getattribute__
return getattr(self._module, attr)
AttributeError: 'module' object has no attribute 'directives'
I can fix the above error, but I worry it's actually just a symptom of Python (within mod_wsgi) being unable to find binary .pyd files inside the "library.zip" runtime bundle that ships with Mercurial python runtime/binaries on Windows, in the lib\site-packages folder.
Update My results after trying the answer below are the same as before; I already figured out how to get Python 2.6 to install into bitnami by doing the registry hack similar to the python script below, and I get this situation, when I'm finished: The plugin installs, and says that there's an error on the main screen:
There are NO useful messages of any kind (no warnings, hints or errors) related to TracMercurial, in trac.log. The failure is silent, and I believe it's due to the .pyd-inside-library.zip crap which I don't know how to work around (the wiki page says do it, but doesn't say HOW).
#2 By: kaysa, June 27th, 2012 07:42
I think that problem is the Mercurial installation. Once I installed the latest BitNami Trac Stack (with Python 2.6) I followed the steps below and the TracMercurial plugin is enabled.
Register in the Windows Registry the Python version include in the BitNami stack. For the registrypython.py script with the following content:
from _winreg import *
installpath = sys.prefix
regpath = "SOFTWARE\\\\Python\\\\Pythoncore\\\\%s\\\\" % version
installkey = "InstallPath"
pythonkey = "PythonPath"
pythonpath = "%s;%s\\\\Lib\\sys.version[:3]\\;%s\\\\DLLs\\\\" % (
installpath, installpath, installpath
reg = OpenKey(HKEY_LOCAL_MACHINE, regpath)
reg = CreateKey(HKEY_LOCAL_MACHINE, regpath)
SetValue(reg, installkey, REG_SZ, installpath)
SetValue(reg, pythonkey, REG_SZ, pythonpath)
print "*** Unable to register!"
print "--- Python", version, "is now registered!"
if (QueryValue(reg, installkey) == installpath and
QueryValue(reg, pythonkey) == pythonpath):
print "=== Python", version, "is already registered!"
print "*** Unable to register!"
print "*** You probably have another Python installation!"
if __name__ == "__main__":
Now execute "python registerpython.py". Please make sure that you have loaded the BitNami environment so python is correctly registered.
Now download Mercurial-2.2.2 (32-bit py2.6) installer. Please use that exact version. The Python version included in BitNami is 32bit so using the 64bit installer may cause problems. You will be asked to confirm the Python version (you should be allowed to use the BitNami version).
Then you just need to follow the guidelines in the TracMercurial plugin page. Make sure that you get the code compatible with Trac 0.12 version. Then execute "python setup.py install" and restart the servers. You should now see the TracMercurial plugin on the list of plugins.
Regarding adding Mercurial and TracMercurial plugin in the stack, we really appreciate your feedback and requests :) our development is driven by the our users requests so we are glad of hearing your suggestions. It is already something that we would like to implement. However it is not as simple, also we may find incompatibilities if for instance if we upgrade to Python 2.7. There are not official Mercurial installer for this version of Python. Apart of that it seems that Git is getting more attraction and even it seems that it has been consider to make it the official repository for Trac 1.x.
In any case we will try to make this easier for the users to get the BitNami Trac Stack working with Mercurial and the first step would be to have an easy way to register the Python version. There are other precompiled modules that look for Python in the registry so that will be an useful addition.
#3 By: WarrenP, June 27th, 2012 09:25
Okay I did all this before, but I did it again, and still get stuck at the same silent failure. See the screenshots above. WHat I don't know how to do is (a) unzip library.zip somewhere, and (b) add that to the bitnami python os.path environment.
#4 By: kaysa, June 27th, 2012 09:30
Ah ok. I now see when you get the error. Have you check that the hg binaries are in the PATH?
#5 By: WarrenP, June 27th, 2012 10:00
Okay which hg binaries? .pyd files etc, are in library.zip, which I unpacked, and added to setenv.bat version of path. There is no "hg.exe" or equivalent in the mercurial-2.2.2 installer listed above.
#6 By: kaysa, June 27th, 2012 10:21
According to the TracMercurial guide if you used the py2.6 version of mercurial you don't need the libraries.zip: "Alternatively you can install the pre-built Mercurial Python modules from http://bitbucket.org/tortoisehg/thg-winbuild/downloads/" Also, it is very weird that you have python27.dll. If you execute the following what do you get?
python -c "from mercurial import ui, hg"
If nothing it means that it is loaded correctly.