Skip to content

Commit 2f94956

Browse files
committed
Depend on subprocess32 on posix systems for python27
And use it in plase of subprocess on posix systems.
1 parent 86f4a4e commit 2f94956

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

lib/matplotlib/compat/subprocess.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
2.7 onwards).
66
- Provides a stub implementation of subprocess members on Google App Engine
77
(which are missing in subprocess).
8+
- Use subprocess32, backport from python 3.2 on Linux/Mac work-around for
9+
https://github.com/matplotlib/matplotlib/issues/5314
810
911
Instead of importing subprocess, other modules should use this as follows:
1012
@@ -15,8 +17,16 @@
1517

1618
from __future__ import absolute_import # Required to import subprocess
1719
from __future__ import print_function
18-
19-
import subprocess
20+
import os
21+
import sys
22+
if os.name == 'posix' and sys.version_info[:2] < (3, 2):
23+
# work around for https://github.com/matplotlib/matplotlib/issues/5314
24+
try:
25+
import subprocess32 as subprocess
26+
except ImportError:
27+
import subprocess
28+
else:
29+
import subprocess
2030

2131
__all__ = ['Popen', 'PIPE', 'STDOUT', 'check_output', 'CalledProcessError']
2232

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
setupext.Six(),
7171
setupext.Dateutil(),
7272
setupext.FuncTools32(),
73+
setupext.Subprocess32(),
7374
setupext.Pytz(),
7475
setupext.Cycler(),
7576
setupext.Tornado(),

setupext.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,30 @@ def get_install_requires(self):
14001400
return []
14011401

14021402

1403+
class Subprocess32(SetupPackage):
1404+
name = "subprocess32"
1405+
1406+
def check(self):
1407+
if sys.version_info[:2] < (3, 2):
1408+
try:
1409+
import subprocess32
1410+
except ImportError:
1411+
return (
1412+
"subprocess was not found. It is an optional dependency"
1413+
" for for python versions prior to 3.2 that improves"
1414+
" functionality on Linux and OSX")
1415+
1416+
return "using subprocess32"
1417+
else:
1418+
return "Not required"
1419+
1420+
def get_install_requires(self):
1421+
if sys.version_info[:2] < (3, 2) and os.name == 'posix':
1422+
return ['subprocess32']
1423+
else:
1424+
return []
1425+
1426+
14031427
class Tornado(OptionalPackage):
14041428
name = "tornado"
14051429

0 commit comments

Comments
 (0)