setupegg.py develop (was: Matplotlib py2app problems)

"Charlie Moad" <cwmoad@...287...> writes:

Change the line to either:
        if (sys.platform=='win32' or sys.platform=='darwin') and sys.frozen:

Done.

This is causing problems on OS X, since (on at least Python 2.4.1 on
Tiger from http://undefined.org/python/) sys.platform is 'darwin' but
sys.frozen does not exist:

sys.platform

'darwin'

sys.frozen

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'frozen'

It looks like the sys.platform check is trying to guard against this
condition, but plain Mac Python without py2app does not have
sys.frozen. I suppose it would be better to check whether sys.frozen
exists and then its truth value. Would the following change work for
everyone?

Index: lib/matplotlib/__init__.py

···

On 2/19/06, Josh Marshall <josh.p.marshall@...287...> wrote:

===================================================================
--- lib/matplotlib/__init__.py (revision 2151)
+++ lib/matplotlib/__init__.py (working copy)
@@ -349,7 +349,7 @@
     if os.path.isdir(path): return path
     
     # py2exe zips pure python, so still need special check
- if (sys.platform=='win32' or sys.platform=='darwin') and sys.frozen:
+ if getattr(sys, 'frozen', None):
         path = os.path.join(os.path.split(sys.path[0])[0], 'matplotlibdata')
         if os.path.isdir(path): return path
         else:

See also: http://pythonmac.org/wiki/FAQ#head-fda52eabc4c64a21d7044d62a49319a7c85faca9

The reason I ran into this was that I installed the svn version with
"setupegg.py develop"�, and there is no mpl-data directory in
lib/matplotlib. I made a symlink to an existing mpl-data directory,
but I wonder if there is some more elegant way for matplotlib to
support setuptools' develop mode?

http://mail.python.org/pipermail/distutils-sig/2005-July/004692.html

--
Jouni

Jouni K Seppanen wrote:

It looks like the sys.platform check is trying to guard against this
condition, but plain Mac Python without py2app does not have
sys.frozen. I suppose it would be better to check whether sys.frozen
exists and then its truth value. Would the following change work for
everyone?

Hi Jouni,

I applied your patch in SVN revision 2166. Thanks for the pointer.

Cheers!
Andrew