Building a binary package of matplotlib for OS-X

Hi all,

As promised, I've been working on building my binary package for matplotlib 0.82 for OS-X. I've got the one for Apple's python2.3 on OS-X 10.3.* working now. I'm having a little trouble with a version for Python 2.4. If I use:

$ sudo python2.4 setup.py install

It seems to work fine (Yahoo!)

But if I use bdist_mpkg, then install the package, I get this when I try to import matplotlib:

>>> import matplotlib
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/__init__.py", line 509, in ?
     defaultParams = {
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/__init__.py", line 245, in wrapper
     ret = func(*args, **kwargs)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/__init__.py", line 318, in _get_data_path
     raise RuntimeError('Could not find the matplotlib data files')
RuntimeError: Could not find the matplotlib data files

I suspect this is a Py2app error (or a setup.py incompatibility with matplotlib), but I don't know where it is looking for the matplotlib data files, so I'm not sure how to debug this.

By the way, if I install with "setup.py install", then remove site-packages/matplotlib, then install with the package, it works, so I guess that means that the data files are being installed outside of site-packages/matplotlib where would that be?

thanks,

-Chris

PS: in another note, I'll post how I'm compiling all this, so you can comment on that.

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

Chris Barker wrote:

Hi all,

As promised, I've been working on building my binary package for matplotlib 0.82 for OS-X. I've got the one for Apple's python2.3 on OS-X 10.3.* working now. I'm having a little trouble with a version for Python 2.4. If I use:

$ sudo python2.4 setup.py install

It seems to work fine (Yahoo!)

But if I use bdist_mpkg, then install the package, I get this when I try to import matplotlib:

>>> import matplotlib
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/__init__.py", line 509, in ?
    defaultParams = {
  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/__init__.py", line 245, in wrapper
    ret = func(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/__init__.py", line 318, in _get_data_path
    raise RuntimeError('Could not find the matplotlib data files')
RuntimeError: Could not find the matplotlib data files

I suspect this is a Py2app error (or a setup.py incompatibility with matplotlib), but I don't know where it is looking for the matplotlib data files, so I'm not sure how to debug this.

By the way, if I install with "setup.py install", then remove site-packages/matplotlib, then install with the package, it works, so I guess that means that the data files are being installed outside of site-packages/matplotlib where would that be?

Probably /System/Libraray/Frameworks/Python.framework/Versions/Current/share/...

I always use the following setup.cfg when building matplotlib:

[install]
install-data=/usr/local

You can check where the package is placing the data files by looking at matplotlib-<etc>.mpkg/Contents/Packages/matplotlib-data-<etc>.pkg/Contents/Info.plist under the IFPkgFlagDefaultLocation key. Note that this isn't quite the same as the install-data. It is usually <install-data>/share/matplotlib.

At my request, matplotlib now searches /usr/local/share/matplotlib by default on OS X.

···

--
Robert Kern
rkern@...376...

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

Robert Kern wrote:

I guess that means that the data files are being installed outside of site-packages/matplotlib where would that be?

Probably /System/Libraray/Frameworks/Python.framework/Versions/Current/share/...

That's where they are put by the 2.3 package

I always use the following setup.cfg when building matplotlib:

[install]
install-data=/usr/local

You can check where the package is placing the data files by looking at matplotlib-<etc>.mpkg/Contents/Packages/matplotlib-data-<etc>.pkg/Contents/Info.plist under the IFPkgFlagDefaultLocation key. Note that this isn't quite the same as the install-data. It is usually <install-data>/share/matplotlib.

At my request, matplotlib now searches /usr/local/share/matplotlib by default on OS X.

The 2.4 package is putting it in:

/usr/local/share/share/matplotlib/

Note the double "share". I'm guessing that's the problem. I don't have the time to dig into this further right now, but if someone just knows how to fix it and can tell me, great!

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

I got this same problem with bdist_mpkg. You can just edit the plist
file to point to the right directory as Robert mentioned. Replace
/usr/local/share with whatever you want.
  As a point of preference, I think the data should be installed in
"System/Libraray/Frameworks/Python.framework/Versions/Current/" since
this is the install root of the rest of matplotlib. Putting it in
/usr/local seems to me like you are putting your build "all over" the
place and losing the notion of the install-root. I reiterate, this is
my opinion so take it fwiw.

- Charlie

Chris Barker wrote:

···

Robert Kern wrote:

I guess that means that the data files are being installed outside of
site-packages/matplotlib where would that be?

Probably
/System/Libraray/Frameworks/Python.framework/Versions/Current/share/...

That's where they are put by the 2.3 package

I always use the following setup.cfg when building matplotlib:

[install]
install-data=/usr/local

You can check where the package is placing the data files by looking
at
matplotlib-<etc>.mpkg/Contents/Packages/matplotlib-data-<etc>.pkg/Contents/Info.plist
under the IFPkgFlagDefaultLocation key. Note that this isn't quite the
same as the install-data. It is usually <install-data>/share/matplotlib.

At my request, matplotlib now searches /usr/local/share/matplotlib by
default on OS X.

The 2.4 package is putting it in:

/usr/local/share/share/matplotlib/

Note the double "share". I'm guessing that's the problem. I don't have
the time to dig into this further right now, but if someone just knows
how to fix it and can tell me, great!

-Chris

Chris Barker wrote:

The 2.4 package is putting it in:

/usr/local/share/share/matplotlib/

Note the double "share". I'm guessing that's the problem. I don't have the time to dig into this further right now, but if someone just knows how to fix it and can tell me, great!

Use --install-data=/usr/local not /usr/local/share . That's probably a bug in matplotlib's setup.py somewhere. Pretty much every other package expects --install-data=/usr/local/share or the like.

/usr/local/<etc> is the place to put these things. /System/Library/<etc> is just inaccessible.

···

--
Robert Kern
rkern@...376...

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

Robert Kern wrote:

Chris Barker wrote:

/usr/local/share/share/matplotlib/

Note the double "share". I'm guessing that's the problem.

Use --install-data=/usr/local not /usr/local/share.

I didn't use --install-data anything! However, perhaps Py2App is.

That's probably a bug in matplotlib's setup.py somewhere. Pretty much every other package expects --install-data=/usr/local/share or the like.

OK, then that would explain why Py2App is appending the extra "share". If the convention is to expect the "share" to be part of install-data, then it shouldn't be in the setup.py. However, I'm a little confused, as then the default would be to put it straight into the python root directory. With a straight "setup.py install" it now goes into:

/Library/...../Versions/2.4/share/matplotlib

so without the share, it would go into:

/Library/...../Versions/2.4/matplotlib

Which really doesn't seem right.

Maybe we could check for a "share" at the end of the given path and only add it if it's not there, but that really feels like a kludge.

/usr/local/<etc> is the place to put these things. /System/Library/<etc> is just inaccessible.

/System/Library is not good, but /Library/... is no less accessible. For another take:

Bob Ippolito wrote:

Using data_files in this manner at all is usually the wrong thing to do anyway. Python packages should really put the files they need into the package, not some semi-random location on the filesystem.

I tend to trust Bob in these matters. What is the logic for putting all that stuff outside of the package directory?

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...