[igt-dev] [PATCH i-g-t 2/2] docs/testplan/conf.py: avoid using shutil include

Mauro Carvalho Chehab mauro.chehab at linux.intel.com
Wed Mar 29 11:19:54 UTC 2023


From: Mauro Carvalho Chehab <mchehab at kernel.org>

This is not available at the builtin python libraries. Avoid
needing it in order to make easier to build with Ubuntu 18.04.

So, use the suggestion for which() from:
	https://stackoverflow.com/questions/377017/test-if-executable-exists-in-python

Signed-off-by: Mauro Carvalho Chehab <mchehab at kernel.org>
---
 docs/testplan/conf.py | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/docs/testplan/conf.py b/docs/testplan/conf.py
index 98cd7a51ff18..a73ad99b09b6 100644
--- a/docs/testplan/conf.py
+++ b/docs/testplan/conf.py
@@ -5,13 +5,28 @@ import os
 import sphinx
 import sys
 
-from shutil import which
-
 # Get Sphinx version
 major, minor, patch = sphinx.version_info[:3]
 
 extensions = []
 
+def which(program):
+    import os
+    def is_exe(fpath):
+        return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
+
+    fpath, fname = os.path.split(program)
+    if fpath:
+        if is_exe(program):
+            return program
+    else:
+        for path in os.environ["PATH"].split(os.pathsep):
+            exe_file = os.path.join(path, program)
+            if is_exe(exe_file):
+                return exe_file
+
+    return None
+
 if which('rst2pdf'):
     extensions.append('rst2pdf.pdfbuilder')
 
@@ -44,8 +59,6 @@ else:
         "sidebarwidth": "400px",
     }
 
-print("Theme: %s" % html_theme)
-
 html_css_files = []
 html_static_path = ['.']
 html_copy_source = False
-- 
2.39.2



More information about the igt-dev mailing list