@@ -53,16 +53,8 @@ class TexManager:
5353 Repeated calls to this constructor always return the same instance.
5454 """
5555
56- cachedir = mpl .get_cachedir ()
57- if cachedir is not None :
58- texcache = os .path .join (cachedir , 'tex.cache' )
59- Path (texcache ).mkdir (parents = True , exist_ok = True )
60- else :
61- # Should only happen in a restricted environment (such as Google App
62- # Engine). Deal with this gracefully by not creating a cache directory.
63- texcache = None
64-
6556 # Caches.
57+ texcache = os .path .join (mpl .get_cachedir (), 'tex.cache' )
6658 rgba_arrayd = {}
6759 grey_arrayd = {}
6860
@@ -99,23 +91,22 @@ class TexManager:
9991 ('text.latex.preamble' , 'text.latex.unicode' , 'text.latex.preview' ,
10092 'font.family' ) + tuple ('font.' + n for n in font_families ))
10193
94+ @cbook .deprecated ("3.3" , alternative = "matplotlib.get_cachedir()" )
95+ @property
96+ def cachedir (self ):
97+ return mpl .get_cachedir ()
98+
10299 @functools .lru_cache () # Always return the same instance.
103100 def __new__ (cls ):
104101 self = object .__new__ (cls )
105102 self ._reinit ()
106103 return self
107104
108105 def _reinit (self ):
109- if self .texcache is None :
110- raise RuntimeError ('Cannot create TexManager, as there is no '
111- 'cache directory available' )
112-
113106 Path (self .texcache ).mkdir (parents = True , exist_ok = True )
114107 ff = rcParams ['font.family' ]
115108 if len (ff ) == 1 and ff [0 ].lower () in self .font_families :
116109 self .font_family = ff [0 ].lower ()
117- elif isinstance (ff , str ) and ff .lower () in self .font_families :
118- self .font_family = ff .lower ()
119110 else :
120111 _log .info ('font.family must be one of (%s) when text.usetex is '
121112 'True. serif will be used by default.' ,
0 commit comments