Message11518

Author hskupin
Recipients
Date 2010-01-27.15:38:50
Content
In short words explained there is a bug when .pyd modules have to be loaded
from inside a zip archive. In my case I want to use mercurial.commands and
importing this module results in the error shown below:

Traceback (most recent call last):
  File "z:/data/testing/run_tests.py", line 11, in <module>
    from mercurial import commands, hg, ui
  File "c:\mozilla-build\python25\lib\commands.pyc", line 9, in <module>
    outtext = commands.getoutput(cmd)
  File "mercurial\i18n.pyc", line 51, in <module>
  File "mercurial\util.pyc", line 17, in <module>
ImportError: No module named osutil

In detail:

To implement automated functional test-runs on Windows I'm using the
MozillaBuild environment
(http://ftp.mozilla.org/pub/mozilla.org/mozilla/libraries/win32/MozillaBuildSetup-Latest.exe)
which comes with a lot of helpful tools. Mercurial is included too but not
as a Python module.

When you want to use Mercurial from inside your Python script you would have
to import the Mercurial modules via:

if sys.platform == 'win32':
    sys.path.append(r'c:\mozilla-build\hg\library.zip')
from mercurial import commands, hg, ui

But doing that and calling a function from commands will cause the mentioned
error above.

Resolution:

There is a workaround to circumvent this bug. Extract the library.zip into
another folder and use that one in your path:

if sys.platform == 'win32':
    sys.path.append(r'c:\mozilla-build-libs\hg')
from mercurial import commands, hg, ui

Now everything works fine.


It really looks like that importing .pyd files from zip archives fail.
History
Date User Action Args
2010-01-27 15:38:51hskupinsetmessageid: <1264606731.45.0.0141945530469.issue2000@mercurial.selenic.com>
2010-01-27 15:38:51hskupinlinkissue2000 messages
2010-01-27 15:38:50hskupincreate