[GRASS-dev] Re: problem with CheckForWx in wxGUI
Michael Barton
michael.barton at asu.edu
Sun Jul 27 04:48:38 EDT 2008
On Jul 27, 2008, at 1:18 AM, Martin Landa wrote:
> Hi,
>
> 2008/7/27 Michael Barton <michael.barton at asu.edu>:
>
> [...]
>
>> try:
>> import wxversion
>> wxversion.select(str(majorVersion))
>> import wx
>>
>> The problem lies in wxversion.select. It is looking for the SOURCE
>> CODE
>> files in a BINARY wxPython installation. They simply are not there.
>> Here is
>> what happens if I run this in the Python interpreter.
>>
>>>>> import wx
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> File
>> "//Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
>> site-packages/wx-2.8-mac-unicode/wx/__init__.py",
>> line 45, in <module>
>> File
>> "//Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
>> site-packages/wx-2.8-mac-unicode/wx/_core.py",
>> line 4, in <module>
>> ImportError: No module named _core_
>>>>>
>>
>> Note, it is checking for _core.py.
>> I have _core.pyo and _core.pyc, but not the source _core.py. I
>> don't have
>> any source files in this binary installation. It works fine and
>> takes up
>> less space I suppose. But this sequence ...
>>
>> import wxversion
>> wxversion.select(str(majorVersion))
>> import wx
>>
>> ...fails not because I have the wrong version, but because I do not
>> have the
>> SOURCE files that it uses to check for the version. This is a bug in
>> wxversion. It should be looking for _core.*, not a specific source
>> file
>> _core.py. If I disable version checking by putting a return at the
>> beginning
>> of CheckForWx(), wxgui loads and runs fine. But we should have a
>> version
>> check (though I don't know if we need to check it in so many
>> modules; at
>> startup should be enough.
>>
>> The following code works fine.
>>
>> def CheckForWx():
>> """Try to import wx module and check its version"""
>>
>> majorVersion = 2.8
>> minorVersion = 1.1
>>
>> try:
>> #import wxversion
>> #wxversion.select(str(majorVersion))
>> import wx
>> version = wx.version().split(' ')[0]
>> if float(version[:3]) < majorVersion:
>> raise ValueError('You are using wxPython version %s' %
>> str(version))
>> if float(version[:3]) == 2.8 and \
>> float(version[4:]) < minorVersion:
>> raise ValueError('You are using wxPython version %s' %
>> str(version))
>>
>> This checks to make sure that the default wxpython installation is
>> 2.8.1.1
>> or higher. If not, it throws an error and does not load wxgui.
>
> Michael, I can just repeat what I said, wxPython ML is right place
> where to ask how to solve this problem. Calling wxversion.select() is
> important here since you can have 2.6 and 2.8 installed on your
> computer. At least on Debian it's quite likely...
I understand that using wxversion can help to ensure that some (but
not all) systems with multiple versions will load the correct one.
Nonetheless, there is a bug in wxversion that makes it fail on systems
that DO have the correct version. This is a more serious problem
because it affects anyone who has a binary installation of wxpython
(most people) that does not include the wxpython source files along
with the object files (at least all Mac users currently and possibly
others).
Trying to find a workaround on the wxPython mailing list or other
place is good, but my experience has been that responses are erratic
and sometimes very slow. It can take quite a while until a developer
actually believes that someone even has a problem. This was the case
with the initial response you received on this issue. It was certainly
the case with the bug in adding widgets to AUI menubars on the Mac.
Until this is solved, CheckForWx using wxversion does not work on the
Mac platform--or on ANY system that has a binary installation of
wxPython that lacks the source file _core.py. A version check is good,
but not when it incorrectly disables the GUI on an entire platform.
There are several other new additions that only work on Linux. We need
to work to keep this cross-platform. I'm happy to search for and to
try out other solutions to this particular issue. However, at this
stage, a version check that is only partly reliable (or even no
version check at all) is better than one that prevents the GUI from
running on systems with correct installations.
This change to CheckForWx at least does a version check on the default
wx. But if you think it is better, we can simply disable CheckForWx
entirely.
Michael
More information about the grass-dev
mailing list