问题描述
我正在尝试在Windows上使用hg-git Mercurial扩展(特定于Windows 7 64位).我安装了Mercurial和Git.我安装了Python 2.5(32位).
I'm trying to use the hg-git Mercurial extension on Windows (Windows 7 64-bit, to be specific). I have Mercurial and Git installed. I have Python 2.5 (32-bit) installed.
我按照 http://hg-git.github.com/上的说明进行安装扩展名.最初的easy_install失败,因为没有Visual Studio 2003就无法编译dulwich.
I followed the instructions on http://hg-git.github.com/ to install the extension. The initial easy_install failed because it was unable to compile dulwich without Visual Studio 2003.
我通过以下方式手动安装了dulwich:
I installed dulwich manually by:
- git clone git://git.samba.org/jelmer/dulwich.git
- cd dulwich
- c:\ Python25 \ python setup.py --pure install
现在,当我运行easy_install hg-git时,它会成功(因为满足了dulwich依赖性).
Now when I run easy_install hg-git, it succeeds (since the dulwich dependency is satisfied).
在我的C:\ Users \ username \ Mercurial.ini中,我有:
In my C:\Users\username\Mercurial.ini, I have:
[extensions]
hgext.bookmarks =
hggit =
当我在命令提示符下键入'hg'时,我看到:"***无法导入扩展名hggit:没有名为hggit的模块"
When I type 'hg' at a command prompt, I see:"*** failed to import extension hggit: No module named hggit"
在我的c:\ Python25文件夹下,我看到的对hggit的唯一引用是Lib\site-packages\hg_git-0.2.1-py2.5.egg
.应该将其提取到某个地方还是应该按原样工作?
Looking under my c:\Python25 folder, the only reference to hggit I see is Lib\site-packages\hg_git-0.2.1-py2.5.egg
. Is this supposed to be extracted somewhere, or should it work as-is?
由于失败,我尝试了hg-git页面上的涉及更多"指令,该指令建议克隆git://github.com/schacon/hg-git.git并在我的Mercurial配置中引用路径.我克隆了存储库,并将扩展文件更改为:
Since that failed, I attempted the "more involved" instructions from the hg-git page that suggested cloning git://github.com/schacon/hg-git.git and referencing the path in my Mercurial configuration. I cloned the repo, and changed my extensions file to look like:
[extensions]
hgext.bookmarks =
hggit = c:\code\hg-git\hggit
现在,当我运行hg时,我看到:***无法从c:\ code \ hg-git \ hggit导入扩展hggit:没有名为dulwich.errors的模块.
Now when I run hg, I see: *** failed to import extension hggit from c:\code\hg-git\hggit: No module named dulwich.errors.
好吧,这告诉我现在正在查找hggit,因为我可以在hg-git \ hggit \ git_handler.py中看到它的调用
Ok, so that tells me that it is finding hggit now, because I can see in hg-git\hggit\git_handler.py that it calls
from dulwich.errors import HangupException
这使我认为dulwich安装不正确,或者未安装在路径中.
That makes me think dulwich is not installed correctly, or not in the path.
更新:
从Python命令行:
From Python command line:
import dulwich
产量Import Error: No module named dulwich
但是,在C:\ Python25 \ Lib \ site-packages下,我确实有一个dulwich-0.5.0-py2.5.egg文件夹,该文件夹似乎已被填充.这是通过上述步骤创建的.我需要采取其他步骤使其成为Python路径"的一部分吗?
However, under C:\Python25\Lib\site-packages, I do have a dulwich-0.5.0-py2.5.egg folder which appears to be populated. This was created by the steps mentioned above. Is there an additional step I need to take to make it part of the Python "path"?
从Python命令行(如答案之一所示):
From Python command line (as suggested in one of the answers):
import pkg_resources
pkg_resources.require('dulwich')
产量[dulwich 0.5.0 (c:\python25\lib\site-packages\dulwich-0.5.0-py2.5.egg)]
那这告诉我什么?导入dulwich失败,但是显然pkg_resources可以找到它.我该如何处理这些信息?
So what does that tell me? Importing dulwich fails, but apparently pkg_resources can find it. What can I do with that information?
推荐答案
您绝对正确. Windows的Mercurial二进制发行版是冻结的"-它们使用与它们捆绑在一起的Python代码和解释器,因此独立于系统PYTHONPATH中安装的软件包.当您在Mercurial.ini中指定hggit扩展名的路径时,hg会尝试使用直接路径导入它,但是dulwich库没有被hg显式导入,并且未与其库捆绑在一起,因此导入失败.
You're absolutely right. Mercurial binary distributions for Windows are 'frozen' - they use the Python code and interpreter bundled with them and therefore independent of packages installed in system PYTHONPATH. When you specify path to hggit extension in Mercurial.ini, hg tries to import it using direct path, but dulwich library is not imported explicitly by hg and doesn't bundled with its library, so the import fails.
可以将Dulwich和HgGit都添加到与hg.exe一起安装的library.zip中,但是对我而言,最好的方法是从源代码中安装所有内容,包括Mercurial,并使用安装在\ Python中的.bat文件执行命令. \脚本.在这种情况下,您将需要:
It is possible to add both Dulwich and HgGit into library.zip that is installed along with hg.exe, but for me the best way is to install everything from source including Mercurial and execute commands using .bat files installed into \Python\Scripts. In this case you will need to:
- 从源头安装Mercurial .这将构建纯"版本,因为Windows用户通常没有Visual Studio或其他用于编译C加速器的编译器.
-
安装Dulwich-我将同时使用最新的主干快照吉特和德威.
- Install Mercurial from source. This builds "pure" version, because Windows users usually don't have Visual Studio or alternative compiler for compiling C speedups.
Install Dulwich - I'd use latest trunk snapshot for both Git and Dulwich.
python setup.py --pure install
python setup.py --pure install
安装最新的HgGit 快照
Install latest HgGit snapshot
python setup.py install
python setup.py install
编辑Mercurial.ini以启用hggit =
Edit Mercurial.ini to enable hggit =
这篇关于如何正确安装dulwich以使hg-git在Windows上正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!