8000 matplotlib data is installed in the matplotlib module like package_data · matplotlib/matplotlib@2acdd18 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2acdd18

Browse files
committed
matplotlib data is installed in the matplotlib module like package_data
svn path=/trunk/matplotlib/; revision=1915
1 parent 3f03686 commit 2acdd18

File tree

4 files changed

+86
-53
lines changed

4 files changed

+86
-53
lines changed

API_CHANGES

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Matplotlib data is installed into the matplotlib module.
2+
This is similar to package_data. This should get rid of
3+
having to check for many possibilties in _get_data_path().
4+
The MATPLOTLIBDATA env key is still checked first to allow
5+
for flexibility.
16

27
1) Separated the color table data from cm.py out into
38
a new file, _cm.py, to make it easier to find the actual

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2005-12-12 Matplotlib data is now installed as package_data in
2+
the matplotlib module. This gets rid of checking the
3+
many possibilities in matplotlib._get_data_path() - CM
4+
15
2005-12-11 Support for setuptools/pkg_resources to build and use
26
matplotlib as an egg. Still allows matplotlib to exist
37
using a traditional distutils install. - ADS

lib/matplotlib/__init__.py

Lines changed: 53 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -367,55 +367,63 @@ def _get_configdir():
367367

368368
def _get_data_path():
369369
'get the path to matplotlib data'
370-
371-
if _have_pkg_resources:
372-
try:
373-
dist = pkg_resources.get_distribution('matplotlib')
374-
except pkg_resources.DistributionNotFound:
375-
# pkg_resources is installed, but setuptools wasn't used into install matplotlib.
376-
used_setuptools_to_install_MPL = False
377-
else:
378-
used_setuptools_to_install_MPL = True
379-
380-
if used_setuptools_to_install_MPL:
381-
req = pkg_resources.Requirement.parse('matplotlib')
382-
path = pkg_resources.resource_filename(req, 'share/matplotlib')
383-
return path
384-
370+
385371
if os.environ.has_key('MATPLOTLIBDATA'):
386372
path = os.environ['MATPLOTLIBDATA']
387373
if os.path.isdir(path): return path
374+
375+
else:
376+
path = os.sep.join([os.path.dirname(__file__), 'mpl-data'])
377+
if os.path.isdir(path): return path
388378

389-
path = os.path.join(distutils.sysconfig.PREFIX, 'share', 'matplotlib')
390-
if os.path.isdir(path): return path
391-
392-
path = '/usr/local/share/matplotlib'
393-
if os.path.isdir(path): return path
394-
395-
path = '/usr/share/matplotlib'
396-
if os.path.isdir(path): return path
397-
398-
path = os.path.join(os.sep.join(__file__.split(os.sep)[:-1]),
399-
'share','matplotlib')
400-
if os.path.isdir(path): return path
401-
402-
path = os.path.join(os.sep.join(__file__.split(os.sep)[:-5]),
403-
'share','matplotlib')
404-
if os.path.isdir(path): return path
405-
406-
# CODE ADDED TO SUPPORT PY2EXE - you will need to copy
407-
# C:\Python23\share\matplotlib into your dist dir. See
408-
# http://starship.python.net/crew/theller/moin.cgi/MatPlotLib
409-
# for more info
410-
411-
if sys.platform=='win32' and sys.frozen:
412-
path = os.path.join(os.path.split(sys.path[0])[0], 'matplotlibdata')
413-
if os.path.isdir(path): return path
414-
else:
415-
# Try again assuming sys.path[0] is a dir not a exe
416-
path = os.path.join(sys.path[0], 'matplotlibdata')
417-
if os.path.isdir(path): return path
418-
379+
# if _have_pkg_resources:
380+
# try:
381+
# dist = pkg_resources.get_distribution('matplotlib')
382+
# except pkg_resources.DistributionNotFound:
383+
# # pkg_resources is installed, but setuptools wasn't used into install matplotlib.
384+
# used_setuptools_to_install_MPL = False
385+
# else:
386+
# used_setuptools_to_install_MPL = True
387+
#
388+
# if used_setuptools_to_install_MPL:
389+
# req = pkg_resources.Requirement.parse('matplotlib')
390+
# path = pkg_resources.resource_filename(req, 'share/matplotlib')
391+
# return path
392+
#
393+
# if os.environ.has_key('MATPLOTLIBDATA'):
394+
# path = os.environ['MATPLOTLIBDATA']
395+
# if os.path.isdir(path): return path
396+
#
397+
# path = os.path.join(distutils.sysconfig.PREFIX, 'share', 'matplotlib')
398+
# if os.path.isdir(path): return path
399+
#
400+
# path = '/usr/local/share/matplotlib'
401+
# if os.path.isdir(path): return path
402+
#
403+
# path = '/usr/share/matplotlib'
404+
# if os.path.isdir(path): return path
405+
#
406+
# path = os.path.join(os.sep.join(__file__.split(os.sep)[:-1]),
407+
# 'share','matplotlib')
408 8000 +
# if os.path.isdir(path): return path
409+
#
410+
# path = os.path.join(os.sep.join(__file__.split(os.sep)[:-5]),
411+
# 'share','matplotlib')
412+
# if os.path.isdir(path): return path
413+
#
414+
# # CODE ADDED TO SUPPORT PY2EXE - you will need to copy
415+
# # C:\Python23\share\matplotlib into your dist dir. See
416+
# # http://starship.python.net/crew/theller/moin.cgi/MatPlotLib
417+
# # for more info
418+
#
419+
# if sys.platform=='win32' and sys.frozen:
420+
# path = os.path.join(os.path.split(sys.path[0])[0], 'matplotlibdata')
421+
# if os.path.isdir(path): return path
422+
# else:
423+
# # Try again assuming sys.path[0] is a dir not a exe
424+
# path = os.path.join(sys.path[0], 'matplotlibdata')
425+
# if os.path.isdir(path): return path
426+
#
419427
raise RuntimeError('Could not find the matplotlib data files')
420428

421429
get_data_path = verbose.wrap('matplotlib data path %s', _get_data_path, always=False)

setup.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@
5757
import os
5858
if os.path.exists('MANIFEST'): os.remove('MANIFEST')
5959

60-
from distutils.core import setup
61-
6260
try:
6361
from setuptools import setup # use setuptools if possible
62+
has_setuptools = True
6463
except ImportError:
65-
pass
64+
from distutils.core import setup
65+
has_setuptools = False
6666

6767
import sys,os
6868
import glob
@@ -81,9 +81,25 @@
8181
if line[:11] == '__version__':
8282
exec(line)
8383
break
84-
84+
85+
# Find the plat-lib dir where mpl will be installed.
86+
# This is where the mpl-data will be installed.
87+
from distutils.command.install import INSTALL_SCHEMES
88+
89+
if has_setuptools: # EGG's make it simple
90+
datapath = os.path.curdir
91+
# logic from distutils.command.install.finalize_options
92+
elif os.name == 'posix':
93+
py_version_short = sys.version[0:3]
94+
datapath = INSTALL_SCHEMES['unix_prefix']['platlib']
95+
datapath = datapath.replace('$platbase/', '').replace('$py_version_short', py_version_short)
96+
else:
97+
datapath = INSTALL_SCHEMES[os.name]['platlib'].replace('$base/', '')
98+
99+
datapath = os.sep.join([datapath, 'matplotlib', 'mpl-data']) # This is where mpl data will be installed
100+
101+
# Specify all the required mpl data
85102
data = []
86-
87103
data.extend(glob.glob('gui/*.glade'))
88104
data.extend(glob.glob('fonts/afm/*.afm'))
89105
data.extend(glob.glob('fonts/ttf/*.ttf'))
@@ -93,10 +109,10 @@
93109
data.extend(glob.glob('images/*.ppm'))
94110
data.append('matplotlibrc')
95111

96-
data_files=[('share/matplotlib', data),]
112+
data_files=[(datapath, data),]
97113

98114
# Needed for CocoaAgg
99-
data_files.append(('share/matplotlib/Matplotlib.nib',
115+
data_files.append((os.sep.join([datapath, 'Matplotlib.nib']),
100116
glob.glob('lib/matplotlib/backends/Matplotlib.nib/*.nib')))
101117

102118
# Figure out which array packages to provide binary support for
@@ -265,7 +281,7 @@ def add_dateutil():
265281

266282

267283

268-
setup(name="matplotlib",
284+
distrib = setup(name="matplotlib",
269285
version= __version__,
270286
description = "Matlab(TM) style python plotting package",
271287
author = "John D. Hunter",

0 commit comments

Comments
 (0)
0