簡體   English   中英

在TRACE上使用Mercurial時,這一次在Windows 2008 R2(64位)上,在“需求導入”中獲取“ DLL加載失敗”或python異常

[英]Getting either “DLL load failed” or python-exception in demandimport, when using mercurial on trac, this time on Windows 2008 R2, 64 bit

這個問題是在2011年提出的,並且在不同的操作系統(XP而不是WSRV2008R2)上聽起來很相似,但是公認的解決方案是返回到較古老的水銀版本1.8。 我認為這不是2012年的好答案。

我想知道是否有一種方法可以使Apache 2.2和Trac 0.12,以及Mercurial 2.2.2在Windows上運行,並且都在Apache下運行。 我遇到的問題似乎與Python編程有關,並且與各種壓縮和未壓縮模塊格式的Python使用以及Mercurial使用有關。

  1. 似乎要使所有這些正常工作,可能需要您在Windows上從源代碼構建Mercurial,或使用Mercurial的“純python”版本。 我想知道Python或Mercurial會導致這些問題,這些問題可能需要我運行“純python”。 也許一個公認的答案是Mercurial是一種古怪的野獸,在mod_wsgi下,應該只使用純Python版本的mercurial。 底層的Python和軟件實現的原因也很重要。

  2. 似乎暗示了Mercurial的幕后需求加載功能,這是Mercurial源碼中的源代碼級功能,這使我感到困惑,我希望有人能對此進行解釋。

  3. 在Mercurial已安裝版本中使用“ library.zip”似乎也造成了運行時的情況,當我從命令行運行python.exe(Windows中的命令提示符,設置了環境和路徑)時,Mercurial將導入(如果我在apache中,則將被設置),但是Mercurial的主要python單元不會使用mod_wsgi從apache中導入。

這是我使用的測試腳本,在命令提示符下工作正常,並顯示此python 2.6實例在site-packages具有一組可行的Mercurial內容:

from mercurial import ui, hg
path = 'D:/MyHgRepo'
repo = hg.repository(ui.ui(), path)
print path,"Repository info:"
print repr(repo), "object len: ",len(repo)

但是,當從Apache內托管的Trac內部運行時,嘗試加載Mercurial模塊的嘗試失敗,首先是由於一個奇怪的demandimport失敗,並且在修復該問題時,無故默默地在Trac中給出了原因(我將不得不在trac中進行調試)解決此問題的源代碼,也許)。 Demandimport.py是site-packages / Mercurial文件夾中的一個模塊。 此異常回溯來自trac.log:

在這兩種情況下,它都會Look in the Trac log for more information. -這里的錯誤消息似乎是問題所在:

Traceback (most recent call last):
  File "build\bdist.win32\egg\trac\loader.py", line 68, in _load_eggs
    entry.load(require=True)
  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'

上述異常可以通過“注釋掉”整個需求導入單元來解決,這很奇怪。 這是我的空“ pass”實現:

# demandimport.py - disabled by warren.

'''
demandimport - disabled in code by warren.
'''

def enable():
    "does nothing"
    pass

def disable():
    "does nothing"
    pass 

上面的hack清除了上面可見的異常,使trac.log中沒有錯誤,但是,Trac中仍然沒有可見的Hg插件。

通過互聯網上的谷歌搜索,我發現:

  1. 安裝到\\ Python2.6系統文件夾中的Windows的Mercurial安裝程序附帶一個“ Library.zip”,其中不僅包含.pyc,還包含.pyd文件。 當在apache下使用mod_wsgi而不是交互式使用Python或通過獨立的http hg serve操作時,這似乎對某些人有效,而對某些人無效。 我已經看到Trac Mercurial插件的作者建議拆包library.zip。 這是我的第一個問題; Library.zip是怎么回事,這是我的問題。

  2. 很多人很難在Windows上從Apache內部運行Python 2.6或2.7,mod_wsgi,Trac和Mercurial。 它們的潛在問題似乎遠遠超出了軟件用戶和安裝人員的解決能力,並且需要一些奧術,或者至少是基本的python編程知識來解決。

這就是為什么我在編程答案網站上問這個問題的原因。 我想了解Python,以及流行的開源軟件包Mercurial,Trac等使用的Python及其庫,模塊和站點軟件包的體系結構,以便可以理解,診斷和調試Mercurial 2.2損壞的Python代碼庫,在mod_wsgi / apache2.2環境中使用時,在我的系統上不起作用。

我正在使用Python 2.6和Trac 0.12,它們都是由Bitnami Trac Stack安裝程序安裝的。 我正在使用通過Merurial網站上的mercurial-2.2-for-x86-for-Python2.6安裝程序安裝的Mercurial 2.2。

發生這種情況是因為安裝了帶有二進制文件(包括一些CPython擴展名)的Mercurial版本無法導入到Web服務器WSGI或CGI或其他Python-in-apache技術內部使用的Python版本中。

解:

A.查找並安裝正確版本的Mercurial二進制文件(包括Mercurial使用的library.zip和CPython二進制擴展名)

B.選擇Mercurial的純100%-python(無CPython二進制擴展名)版本,例如可破解的mercurial:

https://www.mercurial-scm.org/wiki/HackableMercurial

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM