Skip to content

Commit 56a8767

Browse files
mchehabJonathan Corbet
authored andcommitted
scripts: sphinx-pre-install: Make it compatible with Python 3.6
The minimal version requirements we have is 3.9. Yet, the script which detects it is this one. So, let's try supporting an old version here, as we may want to suggest to upgrade Python version to build the docs. Signed-off-by: Mauro Carvalho Chehab <[email protected]> Signed-off-by: Jonathan Corbet <[email protected]> Link: https://lore.kernel.org/r/39d6e27a047bc3cc8208ac5e11fe6ba44faff9c4.1754992972.git.mchehab+huawei@kernel.org
1 parent ca9087f commit 56a8767

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

scripts/sphinx-pre-install.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ def which(prog):
115115
def find_python_no_venv():
116116
# FIXME: does it makes sense now that this script is in Python?
117117

118-
result = subprocess.run(["pwd"], capture_output=True, text=True)
118+
result = SphinxDependencyChecker.run(["pwd"], capture_output=True,
119+
text=True)
119120
cur_dir = result.stdout.strip()
120121

121122
python_names = ["python3", "python"]
@@ -135,12 +136,23 @@ def find_python_no_venv():
135136
def run(*args, **kwargs):
136137
"""Excecute a command, hiding its output by default"""
137138

138-
if not kwargs.get('capture_output', False):
139+
capture_output = kwargs.pop('capture_output', False)
140+
141+
if capture_output:
142+
if 'stdout' not in kwargs:
143+
kwargs['stdout'] = subprocess.PIPE
144+
if 'stderr' not in kwargs:
145+
kwargs['stderr'] = subprocess.PIPE
146+
else:
139147
if 'stdout' not in kwargs:
140148
kwargs['stdout'] = subprocess.DEVNULL
141149
if 'stderr' not in kwargs:
142150
kwargs['stderr'] = subprocess.DEVNULL
143151

152+
# Don't break with older Python versions
153+
if 'text' in kwargs and sys.version_info < (3, 7):
154+
kwargs['universal_newlines'] = kwargs.pop('text')
155+
144156
return subprocess.run(*args, **kwargs)
145157

146158
#

0 commit comments

Comments
 (0)