Skip to content

Commit f836bc3

Browse files
authored
Merge pull request #8334 from anntzer/fix-appveyor-conda-priority
Fix Appveyor build.
2 parents 763fb35 + 0140c84 commit f836bc3

File tree

2 files changed

+23
-42
lines changed

2 files changed

+23
-42
lines changed

appveyor.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ install:
6868
# for obvci_appveyor_python_build_env.cmd
6969
- cmd: conda install -c pelson/channel/development --yes --quiet obvious-ci
7070
# for msinttypes and newer stuff
71-
- cmd: conda config --add channels conda-forge
71+
# conda-forge may serve outdated versions of certain packages (e.g. conda
72+
# itself), so append it to the end of the list.
73+
- cmd: conda config --append channels conda-forge
7274
- cmd: conda config --set show_channel_urls yes
7375
- cmd: conda config --set always_yes true
7476
# For building conda packages

lib/matplotlib/__init__.py

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -575,26 +575,15 @@ def _create_tmp_config_dir():
575575
576576
Returns None if a writable temporary directory could not be created.
577577
"""
578-
import getpass
579-
import tempfile
580-
from matplotlib.cbook import mkdirs
581-
582578
try:
583579
tempdir = tempfile.gettempdir()
584580
except NotImplementedError:
585581
# Some restricted platforms (such as Google App Engine) do not provide
586582
# gettempdir.
587583
return None
588-
try:
589-
username = getpass.getuser()
590-
except KeyError:
591-
username = str(os.getuid())
592-
593-
tempdir = tempfile.mkdtemp(prefix='matplotlib-%s-' % username, dir=tempdir)
594-
595-
os.environ['MPLCONFIGDIR'] = tempdir
596-
597-
return tempdir
584+
configdir = os.environ['MPLCONFIGDIR'] = (
585+
tempfile.mkdtemp(prefix='matplotlib-', dir=tempdir))
586+
return configdir
598587

599588

600589
get_home = verbose.wrap('$HOME=%s', _get_home, always=False)
@@ -805,34 +794,24 @@ def matplotlib_fname():
805794
- Lastly, it looks in `$MATPLOTLIBDATA/matplotlibrc` for a
806795
system-defined copy.
807796
"""
808-
if six.PY2:
809-
cwd = os.getcwdu()
810-
else:
811-
cwd = os.getcwd()
812-
fname = os.path.join(cwd, 'matplotlibrc')
813-
if os.path.exists(fname):
814-
return fname
815-
816-
if 'MATPLOTLIBRC' in os.environ:
817-
path = os.environ['MATPLOTLIBRC']
818-
if os.path.exists(path):
819-
if os.path.isfile(path):
820-
return path
821-
fname = os.path.join(path, 'matplotlibrc')
822-
if os.path.exists(fname):
823-
return fname
824-
825-
configdir = _get_configdir()
826-
if os.path.exists(configdir):
827-
fname = os.path.join(configdir, 'matplotlibrc')
828-
if os.path.exists(fname):
829-
return fname
830-
831-
path = get_data_path() # guaranteed to exist or raise
832-
fname = os.path.join(path, 'matplotlibrc')
833-
if not os.path.exists(fname):
834-
warnings.warn('Could not find matplotlibrc; using defaults')
835797

798+
def gen_candidates():
799+
yield os.path.join(six.moves.getcwd(), 'matplotlibrc')
800+
try:
801+
matplotlibrc = os.environ['MATPLOTLIBRC']
802+
except KeyError:
803+
pass
804+
else:
805+
yield matplotlibrc
806+
yield os.path.join(matplotlibrc, 'matplotlibrc')
807+
yield os.path.join(_get_configdir(), 'matplotlibrc')
808+
yield os.path.join(get_data_path(), 'matplotlibrc')
809+
810+
for fname in gen_candidates():
811+
if os.path.isfile(fname):
812+
break
813+
# Return first candidate that is a file, or last candidate if none is
814+
# valid (in that case, a warning is raised at startup by `rc_params`).
836815
return fname
837816

838817

0 commit comments

Comments
 (0)