Issue2000

Title .pyd modules not found when importing from .zip archives (library.zip)
Priority bug Status chatting
Superseder Nosy List djc, hskupin, kiilerix, pmezard
Assigned To Topics

Created on 2010-01-27.15:38:51 by hskupin, last changed 2010-02-10.17:49:09 by hskupin.

Messages
msg11661 (view) Author: hskupin Date: 2010-02-10.17:49:09
Thanks for the hint. I tried that installer and the correct modules get
installed. Everything works now. Means we can close this bug now. We will
install that module per default in MozillaBuild.
msg11521 (view) Author: kiilerix Date: 2010-01-27.18:36:45
The version available on http://mercurial.selenic.com/ is not intended to be
used from python.

Try with an installer from
http://bitbucket.org/tortoisehg/thg-winbuild/downloads/ matching your python
version.
msg11520 (view) Author: hskupin Date: 2010-01-27.18:25:43
Yes, that version has been downloaded directly from the Mercurial website.
For MozillaBuild 1.4 we still use v1.2.1 but I have also downloaded the most
recent version 1.4.2 which makes no difference.

I already had a quick chat with djc on #Moznet, so I will add him to the
nosy list.
msg11519 (view) Author: kiilerix Date: 2010-01-27.18:18:52
I would like to say and ask what msg11380 says and asks.
msg11518 (view) Author: hskupin Date: 2010-01-27.15:38:50
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-02-10 17:49:09hskupinsetnosy: pmezard, kiilerix, djc, hskupin
messages: + msg11661
2010-01-27 18:36:45kiilerixsetnosy: pmezard, kiilerix, djc, hskupin
messages: + msg11521
2010-01-27 18:25:43hskupinsetnosy: + djc
messages: + msg11520
2010-01-27 18:18:52kiilerixsetstatus: unread -> chatting
nosy: + kiilerix
messages: + msg11519
2010-01-27 16:22:09pmezardsetnosy: + pmezard
2010-01-27 15:38:51hskupincreate