To wxPython developers

Dear developers of wxPython, please visit this link:
http://svn.wxwidgets.org/svn/wx/wxPython/trunk/wxPython/media.py.
Since I don't have access to make the fix, I ask you to change the
line

if sys.modules.has_key('wxPython.wx'):
to
if 'wxPython.wx' in sys.modules:

My proposal looks more clean and also Python 3.0 doesn't have the
has_key() method anymore, so this will aid future headaches. :wink:

I just want to make wxPython source code perfect. It is better to do
if 'wxPython.wx' in sys.modules: rather than if
sys.modules.has_key('wxPython.wx'):

Though the latter gives the exact same functionality as the former, it
is still better to do the former. The reason is that the method
has_key() has been deprecated in Python 3.0, and I can see why. You
might still ask why? Well, because it is ugly. :slight_smile: Guido van Rossum
agrees. The in statement is a very powerful statement. Use it! :slight_smile:

···

On Wed, May 7, 2008 at 6:02 PM, Werner F. Bruhin <werner.bruhin@free.fr> wrote:

Chester,

Chester wrote:

> Dear developers of wxPython, please visit this link:
> http://svn.wxwidgets.org/svn/wx/wxPython/trunk/wxPython/media.py.
> Since I don't have access to make the fix, I ask you to change the
> line
>
> if sys.modules.has_key('wxPython.wx'):
> to
> if 'wxPython.wx' in sys.modules:
>
>
> My proposal looks more clean and also Python 3.0 doesn't have the
> has_key() method anymore, so this will aid future headaches. :wink:
>
>
I am not one of the wxPython experts, but I believe that all this is to
support the old style of imports. I doubt that many people are still using
this (although there is still a bit of stuff hanging around on the wiki) and
if they do they should anyhow switch over to the new namespace stuff.

Good things for you to read:
http://wxpython.org/migrationguide.php
wxPython Style Guide - wxPyWiki
How to Learn wxPython - wxPyWiki

Werner
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

I always strive for perfection, because I am a very pedantic person. Every little bug annoys me to the max and I can’t get over that. I love the fact that this kind of ugly code is going away and also that “all remnants of the old naming scheme will be dropped”. Can’t wait for Python 3.0 and wxPython that’ll be based on it! :wink:

···

On Wed, May 7, 2008 at 10:22 PM, Tim Roberts timr@probo.com wrote:

Chester wrote:

I just want to make wxPython source code perfect. It is better to do

if ‘wxPython.wx’ in sys.modules: rather than if

sys.modules.has_key(‘wxPython.wx’):

You forgot to say “in my opinion.”

Though the latter gives the exact same functionality as the former, it

is still better to do the former. The reason is that the method

has_key() has been deprecated in Python 3.0, and I can see why. You

might still ask why? Well, because it is ugly. :slight_smile: Guido van Rossum

agrees. The in statement is a very powerful statement. Use it! :slight_smile:

There are perhaps 2,000 stylistic improvements that could be made to the wxPython source code to improve its readability. When ranked in order of importance, this change is approximately number 1,920.

I think that’s really the point several of us would like to make. When the time comes to port wxPython to Python 3.0, there are a HUGE number of changes that will be required. This particular one is something that will be handled by the automated tool. It isn’t really productive for you to point it out.

You should also realize that the particular file you targeted (media.py) is automatically generated during the build process, and is required ONLY for backwards compatibility with the old wxPython naming convention. When wxPython does finally move to Python 3.0, my assumption is that all remnants of the old naming scheme will be dropped, so this particular file will no longer exist. Given that, there is absolutely no reason to change this now. Introducing changes for no reason is little more than an opportunity to introduce new bugs.

Tim Roberts, timr@probo.com

Providenza & Boekelheide, Inc.


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

That's no excuse to annoy other people.

···

On 2008-05-07, Chester <wxpythoner@gmail.com> wrote:

I always strive for perfection, because I am a very pedantic
person. Every little bug annoys me to the max and I can't get
over that.

--
Grant Edwards grante Yow! I'm young... I'm
                                  at HEALTHY... I can HIKE
                               visi.com THRU CAPT GROGAN'S LUMBAR
                                                   REGIONS!

UAO Robin!!!!
Fantastic...
Overriding _imaging with PIL it works!!!!

Thx!!!

Robin Dunn ha scritto:

···

Mariano Di Felice wrote:

Hi,
   I'm working with py2app in MacOSX ( tiger intel ), and I would like build an app.
When I launch:
python myscript.py py2app will raise this exception:

Traceback (most recent call last):
File "/Users/mar/Desktop/py2app-0.3.6/py2app/build_app.py", line 548, in _run
   self.run_normal()
File "/Users/mar/Desktop/py2app-0.3.6/py2app/build_app.py", line 600, in run_normal
   mf = self.get_modulefinder()
File "/Users/mar/Desktop/py2app-0.3.6/py2app/build_app.py", line 508, in get_modulefinder
   debug=debug,
File "build/bdist.macosx-10.3-i386/egg/modulegraph/find_modules.py", line 243, in find_modules
   find_needed_modules(mf, scripts, includes, packages)
File "build/bdist.macosx-10.3-i386/egg/modulegraph/find_modules.py", line 179, in find_needed_modules
   path = m.packagepath[0]
TypeError: 'NoneType' object is unsubscriptable

Some of these paths seem a bit squirrelly. Are you sure you have py2app and it's dependencies installed correctly?

I've found that if I comment remove "_imaging" from packages, py2app work properly, but, when I start my app in another Mac, an error will be raised in console containing:
"Import Error: The _imaging C module is not installed"

What if you just specify 'PIL' instead?

--
/\/\ariano Di Felice
Java PHP Python Ruby programmer
with MySQL, PostgreSql, SQLite and Oracle support
Linux Platform Developer
http://www.marianodifelice.it
mariano.difelice@gmail.com
Tel. 0735 703735
Cell +39 339 6407211

Ooooopss, another problem....

When I start my app in another mac, there is this exception:

    "Import Image"
ImportError: No module named Image

any another suggestion???

Robin Dunn ha scritto:

···

Mariano Di Felice wrote:

Hi,
   I'm working with py2app in MacOSX ( tiger intel ), and I would like build an app.
When I launch:
python myscript.py py2app will raise this exception:

Traceback (most recent call last):
File "/Users/mar/Desktop/py2app-0.3.6/py2app/build_app.py", line 548, in _run
   self.run_normal()
File "/Users/mar/Desktop/py2app-0.3.6/py2app/build_app.py", line 600, in run_normal
   mf = self.get_modulefinder()
File "/Users/mar/Desktop/py2app-0.3.6/py2app/build_app.py", line 508, in get_modulefinder
   debug=debug,
File "build/bdist.macosx-10.3-i386/egg/modulegraph/find_modules.py", line 243, in find_modules
   find_needed_modules(mf, scripts, includes, packages)
File "build/bdist.macosx-10.3-i386/egg/modulegraph/find_modules.py", line 179, in find_needed_modules
   path = m.packagepath[0]
TypeError: 'NoneType' object is unsubscriptable

Some of these paths seem a bit squirrelly. Are you sure you have py2app and it's dependencies installed correctly?

I've found that if I comment remove "_imaging" from packages, py2app work properly, but, when I start my app in another Mac, an error will be raised in console containing:
"Import Error: The _imaging C module is not installed"

What if you just specify 'PIL' instead?

--
/\/\ariano Di Felice
Java PHP Python Ruby programmer
with MySQL, PostgreSql, SQLite and Oracle support
Linux Platform Developer
http://www.marianodifelice.it
mariano.difelice@gmail.com
Tel. 0735 703735
Cell +39 339 6407211

Robin Dunn wrote:

What if you just specify 'PIL' instead?

Though that shouldn't be required, there is a PIL "recipe":

If it's broken, it would be nice to know that.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Nothing to do...
My py2app don't works absolutely!!! grrr

If someone knows what can I do, please, I've lost all my hopes...

This is my py2app setup.py script:

from distutils.core import setup
import os

includes=["PIL", "PIL._imaging", "PIL._imagingft", "PIL._imagingmath", "PIL._imagingtk", "Image", "PIL.Image"]
packages = ["PIL", "PIL.Image"]

import py2app
plist = {}
setup(name='test',
   options={ 'py2app': { 'includes':includes, #'packages': packages,
            'compressed': True,
            'optimize': 2,
            'plist': plist } },
   version='0.1',
   app=["test.py"],
   setup_requires=["py2app"],
)

and this is my very simple python script test.py

import Image
import os
import sys
import wx

app = wx.PySimpleApp(0)

Image.new("RGBA", (400,400) )
wx.MessageBox("ciao", "")

app.MainLoop()

Well, compile works well, but when I start my app in a MAC machine without wxpython and PIL, this is the error:

ImportError: The _imaging C module is not installed

Any idea???
I use:
py2app 0.3.6
python 2.5.2
wxPython 2.8.7.1
PIL 1.1.6

I'm tried to install py2app 0.4.2 from svn, but it fails for some reason....

PS: I'm desperate...

···

--
/\/\ariano Di Felice
Java PHP Python Ruby programmer
with MySQL, PostgreSql, SQLite and Oracle support
Linux Platform Developer
http://www.marianodifelice.it
mariano.difelice@gmail.com
Tel. 0735 703735
Cell +39 339 6407211

Hi Robin,

thx for you suggestion... Now I've installed correclty modulegraph from svn and py2app ver 0.4.2
But, when I run
python setup.py py2app raise this exception:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/py2app-0.4.2-py2.5.egg/py2app/build_app.py", line 579, in _run
    self.run_normal()
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/py2app-0.4.2-py2.5.egg/py2app/build_app.py", line 650, in run_normal
    self.create_binaries(py_files, pkgdirs, extensions, loader_files)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/py2app-0.4.2-py2.5.egg/py2app/build_app.py", line 767, in create_binaries
    platfiles = mm.run()
  File "build/bdist.macosx-10.3-i386/egg/macholib/MachOStandalone.py", line 102, in run
    mm.run_file(fn)
  File "build/bdist.macosx-10.3-i386/egg/macholib/MachOGraph.py", line 66, in run_file
    m = self.createNode(MachO, pathname)
  File "build/bdist.macosx-10.3-i386/egg/macholib/MachOStandalone.py", line 23, in createNode
    res = super(FilteredMachOGraph, self).createNode(cls, name)
  File "build/bdist.macosx-10.3-i386/egg/altgraph/ObjectGraph.py", line 148, in createNode
    m = cls(name, *args, **kw)
  File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 61, in __init__
    self.load(file(filename, 'rb'))
  File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 71, in load
    self.load_fat(fh)
  File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 82, in load_fat
    self.load_header(fh, arch.offset, arch.size)
  File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 106, in load_header
    hdr = MachOHeader(self, fh, offset, size, magic, hdr, endian)
  File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 146, in __init__
    self.load(fh)
  File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 178, in load
    raise ValueError("Unknown load command: %d" % (cmd_load.cmd,))
ValueError: Unknown load command: 27
> /Users/mac/test/build/bdist.macosx-10.3-i386/egg/macholib/MachO.py(178)load()
(Pdb)

What is this???

thx

Robin Dunn ha scritto:

···

Mariano Di Felice wrote:

Oh my gold!!!!
If I write easy_install py2app will return:

Searching for py2app
Best match: py2app 0.4.2
Processing py2app-0.4.2-py2.5.egg
py2app 0.4.2 is already the active version in easy-install.pth
Installing py2applet script to /Library/Frameworks/Python.framework/Versions/2.5/bin

Using /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/py2app-0.4.2-py2.5.egg

Processing dependencies for py2app
Searching for modulegraph>=0.7.2dev
Reading modulegraph · PyPI
Reading Python Stuff
Reading modulegraph · PyPI
No local packages or download links found for modulegraph>=0.7.2dev
error: Could not find suitable distribution for Requirement.parse('modulegraph>=0.7.2dev')

The "dev" in the name indicates that the dependency is for a development version of modulegraph. Easy_install can also fetch code from a SVN repository and build an egg for it. Try this:

easy_install http://svn.pythonmac.org/modulegraph/modulegraph/trunk/

--
/\/\ariano Di Felice
Java PHP Python Ruby programmer
with MySQL, PostgreSql, SQLite and Oracle support
Linux Platform Developer
http://www.marianodifelice.it
mariano.difelice@gmail.com
Tel. 0735 703735
Cell +39 339 6407211

Mariano Di Felice wrote:

Hi Robin,

thx for you suggestion... Now I've installed correclty modulegraph from svn and py2app ver 0.4.2
But, when I run
python setup.py py2app raise this exception:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/py2app-0.4.2-py2.5.egg/py2app/build_app.py", line 579, in _run
   self.run_normal()
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/py2app-0.4.2-py2.5.egg/py2app/build_app.py", line 650, in run_normal
   self.create_binaries(py_files, pkgdirs, extensions, loader_files)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/py2app-0.4.2-py2.5.egg/py2app/build_app.py", line 767, in create_binaries
   platfiles = mm.run()
File "build/bdist.macosx-10.3-i386/egg/macholib/MachOStandalone.py", line 102, in run
   mm.run_file(fn)
File "build/bdist.macosx-10.3-i386/egg/macholib/MachOGraph.py", line 66, in run_file
   m = self.createNode(MachO, pathname)
File "build/bdist.macosx-10.3-i386/egg/macholib/MachOStandalone.py", line 23, in createNode
   res = super(FilteredMachOGraph, self).createNode(cls, name)
File "build/bdist.macosx-10.3-i386/egg/altgraph/ObjectGraph.py", line 148, in createNode
   m = cls(name, *args, **kw)
File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 61, in __init__
   self.load(file(filename, 'rb'))
File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 71, in load
   self.load_fat(fh)
File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 82, in load_fat
   self.load_header(fh, arch.offset, arch.size)
File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 106, in load_header
   hdr = MachOHeader(self, fh, offset, size, magic, hdr, endian)
File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 146, in __init__
   self.load(fh)
File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 178, in load
   raise ValueError("Unknown load command: %d" % (cmd_load.cmd,))
ValueError: Unknown load command: 27
> /Users/mac/test/build/bdist.macosx-10.3-i386/egg/macholib/MachO.py(178)load()

(Pdb)

What is this???

Leopard has new segment types in the binaries (shared libs, executables, etc.) so you need a newer macholib module that understands what they are. I have 1.2.1.dev installed here. There is a link to the svn from Python Stuff

···

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

I've tried install newest macholib module from your link, Robin, but the problem was not solved.

I note this:
if my script has no includes and no packages, the exception is:

ImportError: The _imaging C module is not installed

If I add:
packages = ["PIL"]
the exception is:
ImportError: No module named Image

Now, If "Image" and "PIL", from python source, is the same, why py2app consider these different??

Robin Dunn ha scritto:

···

Mariano Di Felice wrote:

Hi Robin,

thx for you suggestion... Now I've installed correclty modulegraph from svn and py2app ver 0.4.2
But, when I run
python setup.py py2app raise this exception:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/py2app-0.4.2-py2.5.egg/py2app/build_app.py", line 579, in _run
   self.run_normal()
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/py2app-0.4.2-py2.5.egg/py2app/build_app.py", line 650, in run_normal
   self.create_binaries(py_files, pkgdirs, extensions, loader_files)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/py2app-0.4.2-py2.5.egg/py2app/build_app.py", line 767, in create_binaries
   platfiles = mm.run()
File "build/bdist.macosx-10.3-i386/egg/macholib/MachOStandalone.py", line 102, in run
   mm.run_file(fn)
File "build/bdist.macosx-10.3-i386/egg/macholib/MachOGraph.py", line 66, in run_file
   m = self.createNode(MachO, pathname)
File "build/bdist.macosx-10.3-i386/egg/macholib/MachOStandalone.py", line 23, in createNode
   res = super(FilteredMachOGraph, self).createNode(cls, name)
File "build/bdist.macosx-10.3-i386/egg/altgraph/ObjectGraph.py", line 148, in createNode
   m = cls(name, *args, **kw)
File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 61, in __init__
   self.load(file(filename, 'rb'))
File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 71, in load
   self.load_fat(fh)
File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 82, in load_fat
   self.load_header(fh, arch.offset, arch.size)
File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 106, in load_header
   hdr = MachOHeader(self, fh, offset, size, magic, hdr, endian)
File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 146, in __init__
   self.load(fh)
File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 178, in load
   raise ValueError("Unknown load command: %d" % (cmd_load.cmd,))
ValueError: Unknown load command: 27
> /Users/mac/test/build/bdist.macosx-10.3-i386/egg/macholib/MachO.py(178)load()

(Pdb)

What is this???

Leopard has new segment types in the binaries (shared libs, executables, etc.) so you need a newer macholib module that understands what they are. I have 1.2.1.dev installed here. There is a link to the svn from Python Stuff

--
/\/\ariano Di Felice
Java PHP Python Ruby programmer
with MySQL, PostgreSql, SQLite and Oracle support
Linux Platform Developer
http://www.marianodifelice.it
mariano.difelice@gmail.com
Tel. 0735 703735
Cell +39 339 6407211