wxPy 2.5.3.0p20041015 - first impressions

Wow, such a quick reply

dot(s) in directory path name:

Robin Dunn:

That has not been true since the introduction of the FAT32 (or vfat)
filesystem. Prior to that the 8.3 filename was hard coded into the file
system data structures themselves. Now the names can be up to 255
characters and multiple dots are allowed...

Chis Mellon:

...Tools that do this are broken. There's plenty of tools that assume
you can't have spaces in filenames also, those ...
However, can you point out any tools that incorrectly deal with
directories with dots in them? I'd be interested, if only so that I
can avoid them....

It is true, that I still have antedeluvian tools software dating from the win95
times. Especially, my cd recording application.
(It seems my machine is showing its age...)

Correction: I just checked the manual, you're misinterperting it. The
fact that the extension seperator is "." does not mean that dots are
only allowed as extension seperators. Python deals fine with
directories that have dots in the name.

You are right, mea culpa.

So, the problem is solved.

Robind Dunn:

- Small bug(?) in wxversion.py. The ..\site-package\wx-** is
registrated twice in sys.path. The duplication is due to *.pth
file and the internal wx dir searching, when updating the sys.path
or something like this. Easy to fix.

Hmm... I thought I was removing any existing paths found. I guess I
forgot to do that.

I did not dive seriously into the wxversion.py. I noticed this
when testing my my psi shell. I also have a small wxPy application,
that displays only the sys.path in a TextCtrl.
(I also always forget to check a path existence in a "sys.path" before
appending it.)

With:
va = '2.5.2.8'
vb = '2.5'
import sys
import wxversion
wxversion.require(vb)
import wx

I get this:

wxPython: 2.5.3.0p.20041015

···

-------
C:\PYTHON23\lib\site-packages\wx-2.5.3-msw-ansi <<<<<<<<<<
C:\jm\jmpy\wxversiontestapp
C:\PYTHON23\PYTHON23.zip
C:\jm\jmpy\wxversiontestapp
C:\PYTHON23\DLLs
C:\PYTHON23\lib
C:\PYTHON23\lib\plat-win
C:\PYTHON23\lib\lib-tk
C:\PYTHON23
C:\jm\jmpy\jmlib
C:\PYTHON23\lib\site-packages
C:\PYTHON23\lib\site-packages\wx-2.5.3-msw-ansi <<<<<<<<<<<

and with:

va = '2.5.2.8'
vb = '2.5'
import sys
#~ import wxversion
#~ wxversion.require(vb)
import wx

I get:
wxPython: 2.5.3.0p.20041015
-------
C:\jm\jmpy\wxversiontestapp
C:\PYTHON23\PYTHON23.zip
C:\jm\jmpy\wxversiontestapp
C:\PYTHON23\DLLs
C:\PYTHON23\lib
C:\PYTHON23\lib\plat-win
C:\PYTHON23\lib\lib-tk
C:\PYTHON23
C:\jm\jmpy\jmlib
C:\PYTHON23\lib\site-packages
C:\PYTHON23\lib\site-packages\wx-2.5.3-msw-ansi

Robin Dunn:

- I have a serious concern with py2exe. py2exe does not like
wxversion.py. Py2exe is working, it is building the exe. Later,
the executable is not recognizing the "wx path". I do not think,

<> that this is a py2exe bug, but more an unpleasant side-effect.

I wondered about this. Does it work if you don't use wxversion but let
it naturally find the default wxPython specified in the wx.pth?

If I take my above test application
with:
va = '2.5.2.8'
vb = '2.5'
import sys
#~ import wxversion
#~ wxversion.require(vb)
import wx

The executable gives:

wxPython: 2.5.3.0p.20041015
-------
C:\JM\JMPY\WXVERSIONTESTAPP\DIST\library.zip

That's ok.

But with:
va = '2.5.2.8'
vb = '2.5'
import sys
import wxversion
wxversion.require(vb)
import wx

The exe is not working. It create a log file with:

Traceback (most recent call last):
  File "testversion.py", line 12, in ?
  File "wxversion.pyc", line 77, in require
AssertionError: Required version of wxPython not found

A last question, I forget in my previous post.
Is it not time to drop the wxPython subdir? All the
demo seems to be wx compliant.

jmf, Switzerland

Jean-Michel Fauth wrote:

Robind Dunn:

- Small bug(?) in wxversion.py. The ..\site-package\wx-** is registrated twice in sys.path. The duplication is due to *.pth file and the internal wx dir searching, when updating the sys.path
or something like this. Easy to fix.

Hmm... I thought I was removing any existing paths found. I guess I forgot to do that.

I did not dive seriously into the wxversion.py. I noticed this
when testing my my psi shell. I also have a small wxPy application,
that displays only the sys.path in a TextCtrl.

Please try the attached. It should now remove any existing dirs from sys.path that match the pattern.

- I have a serious concern with py2exe. py2exe does not like wxversion.py. Py2exe is working, it is building the exe. Later, the executable is not recognizing the "wx path". I do not think,

<> that this is a py2exe bug, but more an unpleasant side-effect.

I wondered about this. Does it work if you don't use wxversion but let it naturally find the default wxPython specified in the wx.pth?

[...]

The exe is not working. It create a log file with:

Traceback (most recent call last):
  File "testversion.py", line 12, in ?
  File "wxversion.pyc", line 77, in require
AssertionError: Required version of wxPython not found

Yes, this should be expected. The wxversion module looks at the filesystem for the dirs in sys.path for a pattern match, but in a py2exe'd program there won't be a match. I'll update the wiki page to mention that there is an incompatibility and that if the programmer is using py2exe or similar that they need to not use wxversion and to make sure that the wxPython version they want to use is found naturally on the sys.path.

Does anybody know if there is a way for wxversion to detect if it is running from a 'bundled' version that works with all py2exe-like tools? If so then it could just return from require() without doing anything.

A last question, I forget in my previous post.
Is it not time to drop the wxPython subdir? All the
demo seems to be wx compliant.

Perhaps starting with 2.6. I would like to have all of the examples in the wiki converted first, and also for the new docs to be more complete.

wxversion.py (6.65 KB)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Does anybody know if there is a way for wxversion to detect if it is running from a 'bundled' version that works with all py2exe-like tools? If so then it could just return from require() without doing anything.

It's certainly possible to check for *specific* tools, but I don't know of anything that would work in general.

Python's 'freeze' utility can be checked for using 'imp.is_frozen("wx")'

For Py2Exe, it looks like 'hasattr(sys, "frozen") would do the trick.

However, it would probably be easier for the app code to make this check for itself, since the developer would know exactly how to detect their bundling tool.

You'd then have 3 situations for applications:

   bundled only - no need for wx.requires, since the correct version is bundled with the app

   unbundled only - call wx.requires unconditionally, since the app is never bundled

   either way - check for the specific bundling tool used by the app, and don't call wx.requires when running inside the bundled version

I was going to suggest using python's import machinery to find the packages, instead of inspecting the filesystem directly, but then I remembered that imp.find_module() doesn't handle zipimports, so py2exe breaks it anyway.

Cheers,
Nick.