8000 Backport PR #14395 on branch v3.1.x (MAINT: work around non-zero exit status of "pdftops -v" command.) by meeseeksmachine · Pull Request #14505 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Backport PR #14395 on branch v3.1.x (MAINT: work around non-zero exit status of "pdftops -v" command.) #14505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,20 @@ def _get_executable_info(name):
If the executable is not one that we know how to query.
"""

def impl(args, regex, min_ver=None):
def impl(args, regex, min_ver=None, ignore_exit_code=False):
# Execute the subprocess specified by args; capture stdout and stderr.
# Search for a regex match in the output; if the match succeeds, the
# first group of the match is the version.
# Return an _ExecInfo if the executable exists, and has a version of
# at least min_ver (if set); else, raise FileNotFoundError.
output = subprocess.check_output(
args, stderr=subprocess.STDOUT, universal_newlines=True)
try:
output = subprocess.check_output(
args, stderr=subprocess.STDOUT, universal_newlines=True)
except subprocess.CalledProcessError as _cpe:
if ignore_exit_code:
output = _cpe.output
else:
raise _cpe
match = re.search(regex, output)
if match:
version = LooseVersion(match.group(1))
Expand Down Expand Up @@ -377,7 +383,8 @@ def impl(args, regex, min_ver=None):
"Failed to find an ImageMagick installation")
return impl([path, "--version"], r"^Version: ImageMagick (\S*)")
elif name == "pdftops":
info = impl(["pdftops", "-v"], "^pdftops version (.*)")
info = impl(["pdftops", "-v"], "^pdftops version (.*)",
ignore_exit_code=True)
if info and not ("3.0" <= info.version
# poppler version numbers.
or "0.9" <= info.version <= "1.0"):
Expand Down
0