Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial extensions not working in Windows 7 x64?

We are test driving Mercurial at work. We don't want to have to enter our user/pass each time we interact with a repository, so we set up the mercurial_keyring extension. We:

  • Installed Python 2.6.5 (32 or 64 bit, depending on the system)
  • Installed setuptools (for easy_install.exe)
  • easy_install keyring
  • easy_install mercurial_keyring

And then made the appropriate changes to %userprofile%/mercurial.ini in the [auth] section. It works fine on my colleague's computer (32bit xp sp3), but it does not work on my machine (Windows 7 Ultimate x64). Also noteworthy, the setuptools had to be built from source on Win 7 x64 (python setup.py bdist_wininst, then run the resulting setuptools-0.6c11.win-amd64.exe).

Using just hg.exe from the Mercurial 1.5 binary installation (the .msi), I get this error when I run hg.exe:

*** failed to import extension mercurial_keyring: No module named mercurial_keyring

I tried to change my mercurial.ini, to specify the path to the mercurial_keyring.py file, instead of having mercurial find it (since it's in the PYTHONPATH).

Old:

[extensions]
mercurial_keyring =

New:

[extensions] mercurial_keyring =
c:/mercurial/extensions/mercurial_keyring.py

The error changes to:

abort: could not import module keyring!

So while providing the path to the mercurial_keyring extension works, the dependent keyring module still cannot be found.

After further investigation, it appears that NO extensions work. They all produce the error:

*** failed to import extension [extension name]: No module named [module name]

It appears that when running hg.exe, it is not aware of PYTHONPATH. I have tried:

  • Python 2.6.5 32 bit
  • Python 2.6.5 64 bit
  • Building Mercurial 1.5 from source with MinGW
  • Building Mercurial 1.5 from source with MSVC9
  • Using hg.exe from the 1.5 binary dist (.msi)
  • Using the hg.py in c:\python26\scripts when building from source
  • Various configurations in %userprofile%/mercurial.ini
  • Using setuptools (easy_install.exe) to install keyring and mercurial_keyring
  • Building keyring and mercurial_keyring from source (python setup.py bdist_wininst)

Nothing works. The closest I've got is using hg.py when building from source. It at least doesn't give me errors, and actually creates %userprofile%/wincrypto_pass.cfg when I enter my credentials. But on subsequent requests, it doesn't enter the credentials automatically. It prompts me for them again.

Interestingly, TortoiseHG is using the keyring. I just can't get it to work on the command line. I think something is going on with Win 7 x64 that is preventing mercurial (hg.exe) from seeing the PYTHONPATH, so it can't find any of the installed modules.

Does anyone have extensions working in Win 7 x64? Specifically with the binary installation of mercurial (not hg.py)?

UPDATE I've found a suitable work around for now. Since TortoiseHG does work with mercurial_keyring, I've simply changed my PATH setup to include the tortoiseHG folder, but not c:\mercurial. Now when I type "hg" at the command line, it's using the hg.exe in the tortoiseHG folder, which works fine. Just the same, this is still a problem with mercurial extensions on Win 7 x64. Answers welcome.

like image 987
Samuel Meacham Avatar asked Apr 02 '10 00:04

Samuel Meacham


3 Answers

Answering my own question with my previous update, since there are no other takers yet.

Suitable workaround: Since TortoiseHG does work with mercurial_keyring, I've simply changed my PATH to include the tortoiseHG folder, and exclude c:\mercurial. Now when I type "hg" at the command line, it's using the hg.exe in the tortoiseHG folder, which works fine with the keyring.

like image 133
Samuel Meacham Avatar answered Nov 09 '22 02:11

Samuel Meacham


I'm using:

  • on Windows Server 2008 SP2 x86:
    • Python 2.6.5 x86
    • Mercurial 1.5.1 x86
    • TortoiseHg 1.0.1 x86
  • on Windows Server 2008 R2:
    • Python 2.6.5 x86
    • Mercurial 1.5.1 x86
    • TortoiseHg 1.0.1 x64

On both setups, all configured extensions are loaded without errors.

All tools are installed using the installers provided on their sites. Mercurial appears before TortoiseHg in PATH. I'm using a common configuration file ~/.hgrc for both tools, and a Mercurial.ini file in TortoiseHg installation folder that is loading just the mercurial_keyring extension.

On the command line I have to input the password every time it's needed, but in TortoiseHg the keyring extensions it's fully working.

From the Keyring Extension page on the Mercurial wiki:

If you are on Windows, we recommend you use TortoiseHg. THG ships with Windows specific keyring backends, without which the mercurial-keyring extension cannot function properly on Windows.

UPDATE http://asimilatorul.com/adapter/post/using-mercurial_keyring-extension-with-mercurial-on-windows/

You can copy the required files from TortoiseHg's library.zip into Mercurial's library.zip:

  • hgext\mercurial_keyring.pyo
  • keyring__init__.pyo
  • keyring\backend.pyo
  • keyring\core.pyo
  • win32_crypto.pyd
like image 27
alexandrul Avatar answered Nov 09 '22 01:11

alexandrul


The extension page states that TortoiseHG has some additional components to make it work on Windows and that it doesn't work properly without them. It sounds like the workaround of referencing the TortoiseHG version may be the easiest way to get it working on Windows.

like image 4
Truan Avatar answered Nov 09 '22 03:11

Truan