Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 40ac5df

Browse files
authored
Merge pull request #10505 from dstansby/backport-which
Remove backport of which()
2 parents af4830e + 4e8868d commit 40ac5df

File tree

2 files changed

+1
-70
lines changed

2 files changed

+1
-70
lines changed

lib/matplotlib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ def checkdep_usetex(s):
567567
dvipng_req = '1.6'
568568
flag = True
569569

570-
if _backports.which("tex") is None:
570+
if shutil.which("tex") is None:
571571
flag = False
572572
warnings.warn('matplotlibrc text.usetex option can not be used unless '
573573
'TeX is installed on your system')

lib/matplotlib/cbook/_backports.py

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,6 @@
1-
from __future__ import absolute_import
2-
3-
import os
4-
import sys
5-
61
import numpy as np
72

83

9-
# Copy-pasted from Python 3.4's shutil.
10-
def which(cmd, mode=os.F_OK | os.X_OK, path=None):
11-
"""Given a command, mode, and a PATH string, return the path which
12-
conforms to the given mode on the PATH, or None if there is no such
13-
file.
14-
15-
`mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result
16-
of os.environ.get("PATH"), or can be overridden with a custom search
17-
path.
18-
19-
"""
20-
# Check that a given file can be accessed with the correct mode.
21-
# Additionally check that `file` is not a directory, as on Windows
22-
# directories pass the os.access check.
23-
def _access_check(fn, mode):
24-
return (os.path.exists(fn) and os.access(fn, mode)
25-
and not os.path.isdir(fn))
26-
27-
# If we're given a path with a directory part, look it up directly rather
28-
# than referring to PATH directories. This includes checking relative to the
29-
# current directory, e.g. ./script
30-
if os.path.dirname(cmd):
31-
if _access_check(cmd, mode):
32-
return cmd
33-
return None
34-
35-
if path is None:
36-
path = os.environ.get("PATH", os.defpath)
37-
if not path:
38-
return None
39-
path = path.split(os.pathsep)
40-
41-
if sys.platform == "win32":
42-
# The current directory takes precedence on Windows.
43-
if not os.curdir in path:
44-
path.insert(0, os.curdir)
45-
46-
# PATHEXT is necessary to check on Windows.
47-
pathext = os.environ.get("PATHEXT", "").split(os.pathsep)
48-
# See if the given file matches any of the expected path extensions.
49-
# This will allow us to short circuit when given "python.exe".
50-
# If it does match, only test that one, otherwise we have to try
51-
# others.
52-
if any(cmd.lower().endswith(ext.lower()) for ext in pathext):
53-
files = [cmd]
54-
else:
55-
files = [cmd + ext for ext in pathext]
56-
else:
57-
# On other platforms you don't have things like PATHEXT to tell you
58-
# what file suffixes are executable, so just pass on cmd as-is.
59-
files = [cmd]
60-
61-
seen = set()
62-
for dir in path:
63-
normdir = os.path.normcase(dir)
64-
if not normdir in seen:
65-
seen.add(normdir)
66-
for thefile in files:
67-
name = os.path.join(dir, thefile)
68-
if _access_check(name, mode):
69-
return name
70-
return None
71-
72-
734
# Copy-pasted from numpy.lib.stride_tricks 1.11.2.
745
def _maybe_view_as_subclass(original_array, new_array):
756
if type(original_array) is not type(new_array):

0 commit comments

Comments
 (0)