Default matplotlib data path (HAS CHANGED)

     I just committed my changes. The simplest approach

    > would be to specify the matplotlib module package_data,
    > but the current cvs layout doesn't tailor to that very
    > well. So I mimicked distutils install command to
    > determine where matplotlib is installed. The datapath is
    > then defined as $platlib/matplotlib/mpl-data. Why this
    > change? If you take a look at
    > matplotlib._get_data_path() you will see. This method
    > has grown to probably 100 lines of code to check for
    > various cases, e.g. py2exe, setuptools, embedding mpl,
    > etc. Now that the data is installed into the matplotlib
    > module you could pretty much reduce to 1 line:
    > "os.sep.join([os.path.dirname(__file__), 'mpl-data'])".
    > This now handles all the cases mentioned above. I left
    > in the initial check for the MATPLOTLIBDATA env key to
    > still allow for some flexibility. I have tested on posix
    > and w/wo setuptools. I am going to check windows right
    > now, but pretty sure it should work. Please check this
    > very carefully before next release as it is a pretty
    > major change. Let me know if anyone encounters a
    > problem.

I'm having some trouble with this on my system. I don't know if
something is screwy with my setuptools because I have setuptools but I
don't have egg

peds-pc311:~/python/projects/matplotlib> python
Python 2.4.1 (#2, Mar 30 2005, 21:51:10)
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import setuptools
from setuptools.command import bdist_egg

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: cannot import name bdist_egg

and my install fails

peds-pc311:~/python/projects/matplotlib> sudo python setup.py install
installing data to ./matplotlib/mpl-data
running install
running build
running build_py
running build_ext
running install_lib
running install_data
copying matplotlibrc -> /usr/./matplotlib/mpl-data

So I replaced the has_setup check with this

try:
    from setuptools.command import bdist_egg
    #from setuptools import setup # use setuptools if possible
    has_setuptools = True
except ImportError:
    from distutils.core import setup
    has_setuptools = False

which works on my system. I hit the same bug with scipy, and the
moral seems to be that you should explicitly check for eggs rather
than just setuptools, because there are some versions of setuptools
floating around w/o eggs.

JDH

That seems a better approach. Did you commit?

···

On 12/14/05, John Hunter <jdhunter@...5...> wrote:

    > I just committed my changes. The simplest approach
    > would be to specify the matplotlib module package_data,
    > but the current cvs layout doesn't tailor to that very
    > well. So I mimicked distutils install command to
    > determine where matplotlib is installed. The datapath is
    > then defined as $platlib/matplotlib/mpl-data. Why this
    > change? If you take a look at
    > matplotlib._get_data_path() you will see. This method
    > has grown to probably 100 lines of code to check for
    > various cases, e.g. py2exe, setuptools, embedding mpl,
    > etc. Now that the data is installed into the matplotlib
    > module you could pretty much reduce to 1 line:
    > "os.sep.join([os.path.dirname(__file__), 'mpl-data'])".
    > This now handles all the cases mentioned above. I left
    > in the initial check for the MATPLOTLIBDATA env key to
    > still allow for some flexibility. I have tested on posix
    > and w/wo setuptools. I am going to check windows right
    > now, but pretty sure it should work. Please check this
    > very carefully before next release as it is a pretty
    > major change. Let me know if anyone encounters a
    > problem.

I'm having some trouble with this on my system. I don't know if
something is screwy with my setuptools because I have setuptools but I
don't have egg

peds-pc311:~/python/projects/matplotlib> python
Python 2.4.1 (#2, Mar 30 2005, 21:51:10)
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import setuptools
>>> from setuptools.command import bdist_egg
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: cannot import name bdist_egg
>>>

and my install fails

peds-pc311:~/python/projects/matplotlib> sudo python setup.py install
installing data to ./matplotlib/mpl-data
running install
running build
running build_py
running build_ext
running install_lib
running install_data
copying matplotlibrc -> /usr/./matplotlib/mpl-data

So I replaced the has_setup check with this

try:
    from setuptools.command import bdist_egg
    #from setuptools import setup # use setuptools if possible
    has_setuptools = True
except ImportError:
    from distutils.core import setup
    has_setuptools = False

which works on my system. I hit the same bug with scipy, and the
moral seems to be that you should explicitly check for eggs rather
than just setuptools, because there are some versions of setuptools
floating around w/o eggs.

JDH

Btw, the best approach would to specify the data as package-data
(since that is what it is), and it would be the most compatible.
Unfortunately my attempt to use parent directory relative paths
failed. Taking this approach would actually require moving all the
mpl data into the lib/matplotlib/mpl-data directory in cvs. I thought
you might be opposed to that, hence I have the logic in the setup
file.

- Charlie

···

On 12/14/05, Charlie Moad <cwmoad@...149...> wrote:

That seems a better approach. Did you commit?

On 12/14/05, John Hunter <jdhunter@...5...> wrote:

>
> > I just committed my changes. The simplest approach
> > would be to specify the matplotlib module package_data,
> > but the current cvs layout doesn't tailor to that very
> > well. So I mimicked distutils install command to
> > determine where matplotlib is installed. The datapath is
> > then defined as $platlib/matplotlib/mpl-data. Why this
> > change? If you take a look at
> > matplotlib._get_data_path() you will see. This method
> > has grown to probably 100 lines of code to check for
> > various cases, e.g. py2exe, setuptools, embedding mpl,
> > etc. Now that the data is installed into the matplotlib
> > module you could pretty much reduce to 1 line:
> > "os.sep.join([os.path.dirname(__file__), 'mpl-data'])".
> > This now handles all the cases mentioned above. I left
> > in the initial check for the MATPLOTLIBDATA env key to
> > still allow for some flexibility. I have tested on posix
> > and w/wo setuptools. I am going to check windows right
> > now, but pretty sure it should work. Please check this
> > very carefully before next release as it is a pretty
> > major change. Let me know if anyone encounters a
> > problem.
>
> I'm having some trouble with this on my system. I don't know if
> something is screwy with my setuptools because I have setuptools but I
> don't have egg
>
> peds-pc311:~/python/projects/matplotlib> python
> Python 2.4.1 (#2, Mar 30 2005, 21:51:10)
> [GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import setuptools
> >>> from setuptools.command import bdist_egg
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> ImportError: cannot import name bdist_egg
> >>>
>
> and my install fails
>
> peds-pc311:~/python/projects/matplotlib> sudo python setup.py install
> installing data to ./matplotlib/mpl-data
> running install
> running build
> running build_py
> running build_ext
> running install_lib
> running install_data
> copying matplotlibrc -> /usr/./matplotlib/mpl-data
>
>
> So I replaced the has_setup check with this
>
> try:
> from setuptools.command import bdist_egg
> #from setuptools import setup # use setuptools if possible
> has_setuptools = True
> except ImportError:
> from distutils.core import setup
> has_setuptools = False
>
>
> which works on my system. I hit the same bug with scipy, and the
> moral seems to be that you should explicitly check for eggs rather
> than just setuptools, because there are some versions of setuptools
> floating around w/o eggs.
>
> JDH
>

try:
    from setuptools.command import bdist_egg
    #from setuptools import setup # use setuptools if possible
    has_setuptools = True
except ImportError:
    from distutils.core import setup
    has_setuptools = False

Won't setup not be defined if there is an ImportError? This instead?

try:
    from setuptools.command import bdist_egg
    has_setuptools = True
except ImportError:
    has_setuptools = False
from distutils.core import setup