File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 7373except ImportError :
7474 import subprocess
7575
76+ # Python 3.4 and earlier require contextlib2 for temporarily redirecting stderr and stdout
77+ if sys .version_info < (3 , 5 ):
78+ from contextlib2 import redirect_stdout , redirect_stderr
79+ else :
80+ from contextlib import redirect_stdout , redirect_stderr
81+
7682# Detect whether IPython is installed to determine if the built-in "ipy" command should be included
7783ipython_available = True
7884try :
9298# BrokenPipeError is only in Python 3. Use IOError for Python 2.
9399if six .PY3 :
94100 BROKEN_PIPE_ERROR = BrokenPipeError
95-
96- # redirect_stdout and redirect_stderr weren't added to contextlib until Python 3.4
97- from contextlib import redirect_stdout , redirect_stderr
98101else :
99102 BROKEN_PIPE_ERROR = IOError
100- from contextlib2 import redirect_stdout , redirect_stderr
101103
102104# On some systems, pyperclip will import gtk for its clipboard functionality.
103105# The following code is a workaround for gtk interfering with printing from a background
Original file line number Diff line number Diff line change 6767if sys .platform .startswith ('win' ):
6868 INSTALL_REQUIRES += ['pyreadline' ]
6969
70- # Python 2.7 also requires contextlib2 for temporarily redirecting stdout and stderr and subprocess32
70+ # Python 3.4 and earlier require contextlib2 for temporarily redirecting stderr and stdout
71+ if sys .version_info < (3 , 5 ):
72+ INSTALL_REQUIRES += ['contextlib2' ]
73+
74+ # Python 2.7 also requires subprocess32
7175if sys .version_info < (3 , 0 ):
72- INSTALL_REQUIRES += ['contextlib2' , ' subprocess32' ]
76+ INSTALL_REQUIRES += ['subprocess32' ]
7377
7478# unittest.mock was added in Python 3.3. mock is a backport of unittest.mock to all versions of Python
7579TESTS_REQUIRE = ['mock' , 'pytest' ]
You can’t perform that action at this time.
0 commit comments