Skip to content

Commit efa9ea6

Browse files
committed
made new dfault config file dir .matplotlib
svn path=/trunk/matplotlib/; revision=1538
1 parent 1f0fb59 commit efa9ea6

File tree

13 files changed

+209
-65
lines changed

13 files changed

+209
-65
lines changed

API_CHANGES

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11

2-
API Changes in matplotlib-0.82.1
2+
API Changes in matplotlib-0.83
3+
4+
Made HOME/.matplotlib the new config dir where the matplotlibrc
5+
file, the ttf.cache, and the tex.cache live. The new default
6+
filenames in .matplotlib have no leading dot and are not hidden.
7+
Eg, the new names are matplotlibrc tex.cache ttffont.cache. This is
8+
how ipython does it so it must be right.
9+
10+
If old files are found, a warning is issued and they are
11+
moved to the new location.
312

413
backends/__init__.py no longer imports new_figure_manager,
514
draw_if_interactive and show from the default backend, but puts

CHANGELOG

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
New entries should be added at the top
22

3+
2005-07-06 Made HOME/.matplotlib the new config dir where the
4+
matplotlibrc file, the ttf.cache, and the tex.cache live.
5+
The new default filenames in .matplotlib have no leading
6+
dot and are not hidden. Eg, the new names are matplotlibrc
7+
tex.cache ttffont.cache. This is how ipython does it so it
8+
must be right. If old files are found, a warning is issued
9+
and they are moved to the new location. Also fixed
10+
texmanager to put all files, including temp files in
11+
~/.matplotlib/tex.cache, which allows you to usetex in
12+
non-writable dirs.
13+
14+
315
2005-07-05 Fixed bug #1231611 in subplots adjust layout. The problem
416
was that the text cacheing mechanism was not using the
517
transformation affine in the key. - JDH

LICENSE/LICENSE

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
LICENSE AGREEMENT FOR MATPLOTLIB 0.82
1+
LICENSE AGREEMENT FOR MATPLOTLIB 0.83a
22
--------------------------------------
33

44
1. This LICENSE AGREEMENT is between John D. Hunter ("JDH"), and the
@@ -9,30 +9,30 @@ documentation.
99
2. Subject to the terms and conditions of this License Agreement, JDH
1010
hereby grants Licensee a nonexclusive, royalty-free, world-wide license
1111
to reproduce, analyze, test, perform and/or display publicly, prepare
12-
derivative works, distribute, and otherwise use matplotlib 0.82
12+
derivative works, distribute, and otherwise use matplotlib 0.83a
1313
alone or in any derivative version, provided, however, that JDH's
1414
License Agreement and JDH's notice of copyright, i.e., "Copyright (c)
1515
2002-2005 John D. Hunter; All Rights Reserved" are retained in
16-
matplotlib 0.82 alone or in any derivative version prepared by
16+
matplotlib 0.83a alone or in any derivative version prepared by
1717
Licensee.
1818

1919
3. In the event Licensee prepares a derivative work that is based on or
20-
incorporates matplotlib 0.82 or any part thereof, and wants to
20+
incorporates matplotlib 0.83a or any part thereof, and wants to
2121
make the derivative work available to others as provided herein, then
2222
Licensee hereby agrees to include in any such work a brief summary of
23-
the changes made to matplotlib 0.82.
23+
the changes made to matplotlib 0.83a.
2424

25-
4. JDH is making matplotlib 0.82 available to Licensee on an "AS
25+
4. JDH is making matplotlib 0.83a available to Licensee on an "AS
2626
IS" basis. JDH MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
2727
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, JDH MAKES NO AND
2828
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
29-
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF MATPLOTLIB 0.82
29+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF MATPLOTLIB 0.83a
3030
WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
3131

3232
5. JDH SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF MATPLOTLIB
33-
0.82 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR
33+
0.83a FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR
3434
LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING
35-
MATPLOTLIB 0.82, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF
35+
MATPLOTLIB 0.83a, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF
3636
THE POSSIBILITY THEREOF.
3737

3838
6. This License Agreement will automatically terminate upon a material
@@ -44,6 +44,6 @@ Licensee. This License Agreement does not grant permission to use JDH
4444
trademarks or trade name in a trademark sense to endorse or promote
4545
products or services of Licensee, or any third party.
4646

47-
8. By copying, installing or otherwise using matplotlib 0.82,
47+
8. By copying, installing or otherwise using matplotlib 0.83a,
4848
Licensee agrees to be bound by the terms and conditions of this License
4949
Agreement.

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include API_CHANGES CHANGELOG KNOWN_BUGS INSTALL NUMARRAY_ISSUES
22
include INTERACTIVE TODO
33
include Makefile MANIFEST.in MANIFEST
4-
include .matplotlibrc
4+
include matplotlibrc
55
include __init__.py setupext.py setup.py makeswig.py
66
include examples/data/*
77
include images/*

examples/tex_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
title(r"\TeX\ is Number $\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!",
2929
fontsize=16, color='r')
3030
grid(True)
31-
savefig('tex_demo.eps')
31+
#savefig('tex_demo.eps')
3232

3333

3434
show()

lib/matplotlib/__init__.py

Lines changed: 138 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
"""
143143
from __future__ import generators
144144

145-
__version__ = '0.82'
145+
__version__ = '0.83a'
146146
__revision__ = '$Revision$'
147147
__date__ = '$Date$'
148148

@@ -159,13 +159,13 @@
159159
160160
- environment variable MATPLOTLIBRC
161161
162-
- HOME/.matplotlibrc if HOME is defined
162+
- HOME/.matplotlib/matplotlibrc if HOME is defined
163163
164-
- PATH/.matplotlibrc where PATH is the return value of
164+
- PATH/matplotlibrc where PATH is the return value of
165165
get_data_path()
166166
"""
167167

168-
import sys, os
168+
import sys, os, tempfile
169169

170170

171171
major, minor1, minor2, s, tmp = sys.version_info
@@ -186,6 +186,21 @@ def enumerate(seq):
186186
yield i, seq[i]
187187

188188

189+
190+
def _is_writable_dir(p):
191+
"""
192+
p is a string pointing to a putative writable dir -- return True p
193+
is such a string, else False
194+
"""
195+
try: p + '' # test is string like
196+
except TypeError: return False
197+
try:
198+
t = tempfile.TemporaryFile(dir=p)
199+
t.write('1')
200+
t.close()
201+
except OSError: return False
202+
else: return True
203+
189204
class Verbose:
190205
"""
191206
A class to handle reporting. Set the fileo attribute to any file
@@ -259,23 +274,65 @@ def ge(self, level):
259274

260275
verbose=Verbose('silent')
261276

262-
def get_home():
277+
278+
def _get_home():
279+
"""Return the closest possible equivalent to a 'home' directory.
280+
281+
We first try $HOME. Absent that, on NT it's USERPROFILE if
282+
defined, else, $HOMEDRIVE\$HOMEPATH, else C:\
283+
263284
"""
264-
return the users HOME dir across platforms or None.
265-
266-
On win32, if either HOME is not set or HOME is set but doesn't
267-
exist, the value of USERPROFILE will be used instead.
285+
286+
287+
try: return os.environ['HOME']
288+
except KeyError: pass
289+
290+
if os.name == 'nt':
291+
# For some strange reason, win9x returns 'nt' for os.name.
292+
293+
try: p = os.environ['USERPROFILE']
294+
except KeyError: pass
295+
else:
296+
if os.path.exists(p): return p
297+
298+
try: p = os.path.join(os.environ['HOMEDRIVE'],os.environ['HOMEPATH'])
299+
except KeyError: pass
300+
else:
301+
if os.path.exists(p): return p
302+
303+
try:
304+
import _winreg as wreg
305+
key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
306+
'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders')
307+
p = wreg.QueryValueEx(key,'Personal')[0]
308+
key.Close()
309+
if os.path.exists(p): return p
310+
except: pass
311+
return 'C:\\'
312+
313+
raise RuntimeError('please define environment variable $HOME')
314+
315+
316+
317+
318+
get_home = verbose.wrap('$HOME=%s', _get_home, always=False)
319+
320+
def _get_configdir():
268321
"""
322+
Return the string representing the configuration dir. If s is the
323+
special string _default_, use HOME/.matplotlib. s must be writable
324+
"""
325+
h = get_home()
326+
if not _is_writable_dir(h):
327+
raise RuntimeError("'%s' is not a writable dir; you must set environment variable HOME to be a writable dir "%h)
269328

270-
if os.environ.has_key('HOME'):
271-
path = os.environ['HOME']
272-
if os.path.exists(path): return path
329+
p = os.path.join(get_home(), '.matplotlib')
273330

274-
if sys.platform=='win32' and os.environ.has_key('USERPROFILE'):
275-
path = os.environ['USERPROFILE']
276-
if os.path.exists(path): return path
331+
if not _is_writable_dir(p):
332+
os.mkdir(p)
277333

278-
return None
334+
return p
335+
get_configdir = verbose.wrap('$HOME=%s', _get_configdir, always=False)
279336

280337

281338
def _get_data_path():
@@ -320,6 +377,7 @@ def _get_data_path():
320377
get_data_path = verbose.wrap('matplotlib data path %s', _get_data_path, always=False)
321378

322379

380+
323381
def validate_path_exists(s):
324382
'If s is a path, return s, else False'
325383
if os.path.exists(s): return s
@@ -594,7 +652,7 @@ def __call__(self, s):
594652

595653
'grid.color' : ['k', validate_color], # grid color
596654
'grid.linestyle' : [':', str], # dotted
597-
'grid.linewidth' : ['0.5', validate_float], # in points
655+
'grid.linewidth' : [0.5, validate_float], # in points
598656

599657

600658
# figure props
@@ -628,17 +686,9 @@ def __call__(self, s):
628686
}
629687

630688

631-
def matplotlib_fname():
689+
def _old_matplotlib_fname():
632690
"""
633-
Return the path to the rc file
634-
635-
Search order:
636-
637-
* current working dir
638-
* environ var MATPLOTLIBRC
639-
* HOME/.matplotlibrc
640-
* MATPLOTLIBDATA/.matplotlibrc
641-
691+
Return the path to the rc file using the old search method
642692
"""
643693

644694
fname = os.path.join( os.getcwd(), '.matplotlibrc')
@@ -663,6 +713,60 @@ def matplotlib_fname():
663713
warnings.warn('Could not find .matplotlibrc; using defaults')
664714
return fname
665715

716+
def matplotlib_fname():
717+
"""
718+
Return the path to the rc file
719+
720+
Search order:
721+
722+
* current working dir
723+
* environ var MATPLOTLIBRC
724+
* HOME/.matplotlib/matplotlibrc
725+
* MATPLOTLIBDATA/matplotlibrc
726+
727+
728+
"""
729+
730+
oldname = os.path.join( os.getcwd(), '.matplotlibrc')
731+
if os.path.exists(oldname):
732+
print >> sys.stderr, """\
733+
WARNING: Old rc filename ".matplotlibrc" found in working dir
734+
and and renamed to new default rc file name "matplotlibrc"
735+
(no leading"dot"). """
736+
os.rename('.matplotlibrc', 'matplotlibrc')
737+
738+
home = get_home()
739+
oldname = os.path.join( home, '.matplotlibrc')
740+
if os.path.exists(oldname):
741+
configdir = get_configdir()
742+
newname = os.path.join(configdir, 'matplotlibrc')
743+
print >> sys.stderr, """\
744+
WARNING: Old rc filename "%s" found and renamed to
745+
new default rc file name "%s"."""%(oldname, newname)
746+
747+
os.rename(oldname, newname)
748+
749+
750+
fname = os.path.join( os.getcwd(), 'matplotlibrc')
751+
if os.path.exists(fname): return fname
752+
753+
if os.environ.has_key('MATPLOTLIBRC'):
754+
path = os.environ['MATPLOTLIBRC']
755+
if os.path.exists(path):
756+
fname = os.path.join(path, 'matplotlibrc')
757+
if os.path.exists(fname):
758+
return fname
759+
760+
fname = os.path.join(get_configdir(), 'matplotlibrc')
761+
if os.path.exists(fname): return fname
762+
763+
764+
path = get_data_path() # guaranteed to exist or raise
765+
fname = os.path.join(path, 'matplotlibrc')
766+
if not os.path.exists(fname):
767+
warnings.warn('Could not find matplotlibrc; using defaults')
768+
return fname
769+
666770

667771

668772
def rc_params():
@@ -699,7 +803,7 @@ def rc_params():
699803
key = key.strip()
700804
if key in deprecated_map.keys():
701805
alt = deprecated_map[key]
702-
warnings.warn('%s is deprecated in .matplotlibrc - use %s instead.' % (key, alt))
806+
warnings.warn('%s is deprecated in matplotlibrc - use %s instead.' % (key, alt))
703807
key = alt
704808

705809
if not defaultParams.has_key(key):
@@ -809,6 +913,12 @@ def rcdefaults():
809913
rcParams.update(rcParamsDefault)
810914

811915

916+
917+
918+
919+
920+
921+
812922

813923
# Now allow command line to override
814924

lib/matplotlib/axes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,9 +2750,9 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
27502750
faceted=True,
27512751
**kwargs):
27522752
"""
2753-
SCATTER(x, y, s=20, c='b', marker='o', cmap=None, norm=None,
2754-
vmin=None, vmax=None, alpha=1.0)
2755-
2753+
SCATTER(x, y, s=20, c='b', marker='o', cmap=None, norm=None,
2754+
vmin=None, vmax=None, alpha=1.0, linewidths=None,
2755+
faceted=True, **kwargs)
27562756
Supported function signatures:
27572757
27582758
SCATTER(x, y) - make a scatter plot of x vs y

lib/matplotlib/backends/backend_gtk.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def fn_name(): return sys._getframe(1).f_code.co_name
2020

2121
from backend_gdk import RendererGDK
2222

23+
2324
pygtk_version_required = (2,0,0)
2425
try:
2526
import pygtk

lib/matplotlib/backends/backend_ps.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,9 @@ def print_figure(self, outfile, dpi=72,
935935
# need to make some temporary files so latex can run without
936936
# writing over something important.
937937
m = md5.md5(outfile)
938-
tmpname = m.hexdigest()
938+
tmpname = os.path.join(TexManager.texcache, m.hexdigest())
939+
os.environ['TEXMFOUTPUT'] = TexManager.texcache
940+
939941
epsfile = tmpname + '.eps'
940942
psfile = tmpname + '.ps'
941943
texfile = tmpname + '.tex'

0 commit comments

Comments
 (0)