2012-06-25 20 views
1

This question,2011年問及在不同的操作系統上(XP代替WSRV2008R2),在demandimport中獲取「DLL加載失敗」或python異常是一個聽起來非常相似的人,但接受的解決方案是回到現在的古老的水銀版本1.8。我不認爲這是在2012年的好回答。當在trac上使用mercurial時,在Windows 2008 R2,64位

我想知道是否有辦法獲得Apache 2.2和Trac 0.12,和Mercurial 2.2.2在Windows上工作,並且所有在Apache下運行。我遇到的問題似乎是與編程相關的Python ,與Python的使用以及Mercurial的使用有關,這些問題與各種壓縮和解壓縮模塊格式有關。

  1. 似乎讓這一切的工作,可能需要建立從源善變,在Windows上,或者用水銀的「純Python」版本。我想知道什麼是Python,或者Mercurial,導致這些問題可能需要我運行「純粹的Python」。也許有人接受的答案是Mercurial是一個古怪的野獸,在mod_wsgi下,應該只使用純粹的mercurial版本。底層的Python和mercurial實現的原因也是很重要的。

  2. 看起來Mercurial的陰暗看起來需求加載功能是牽連的,這是一個源代碼水平的功能,這使我很困惑,我希望有人能解釋它。

  3. 在mercurial安裝版本的「library.zip」中的使用似乎也創建了一個運行時情況,當我從命令行運行python.exe時,mercurial會導入(Windows中的命令提示符,環境和路徑設置,因爲它會被設置,如果我在apache裏面),但是Mercurial的主要python單元不能從apache內部導入mod_wsgi。

下面是測試腳本,我用它工作正常,從命令提示符,並表明這條巨蟒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) 

然而,當從Trac內部運行,它位於Apache的內部時,加載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' 

上述異常可以通過固定的,奇怪的是「評論」整個需求進口單位。這是我的空「通」的實施:

# demandimport.py - disabled by warren. 

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

def enable(): 
    "does nothing" 
    pass 

def disable(): 
    "does nothing" 
    pass 

上述黑客清除了上述可見例外,留下trac.log沒有錯誤的,然而,仍然沒有汞的插件內的Trac可見。

從谷歌上搜索,瘋狂地在互聯網,我發現:

  1. 適合Windows,安裝到\ python2.6的系統文件夾水銀安裝,船舶,不僅包含「Library.zip」 .pyc還有.pyd文件。這似乎適用於某些人,並且在某些人使用mod_wsgi在apache下使用,而不是在交互式使用Python時,或者通過獨立HTTP hg serve操作時失敗。我見過Trac Mercurial Plugin的作者建議解壓縮library.zip。這是我的第一個問題; Library.zip發生了什麼,是我的問題。

  2. 很多人都很難獲得Python 2.6或2.7,mod_wsgi,Trac和Mercurial,它們都可以從Apache內部的Windows上運行。他們所面臨的潛在問題似乎遠遠超出了軟件用戶和安裝人員解決問題的能力,並且需要一些神祕的東西,或者至少需要基本的python編程知識才能解決。

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

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

回答

0

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

解決方案:

A.查找並安裝善變的二進制文件(包括水銀使用的library.zip和CPython的二進制擴展)

B.去一個純100%-python(正確版本沒有CPython二進制擴展)Mercurial的版本,比如hackable mercurial:

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

相關問題