Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mauro.chehab@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 2/2] docs/testplan/conf.py: avoid using shutil include
Date: Wed, 29 Mar 2023 13:19:54 +0200	[thread overview]
Message-ID: <20230329111954.2584660-3-mauro.chehab@linux.intel.com> (raw)
In-Reply-To: <20230329111954.2584660-1-mauro.chehab@linux.intel.com>

From: Mauro Carvalho Chehab <mchehab@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@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

  parent reply	other threads:[~2023-03-29 11:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-29 11:19 [igt-dev] [PATCH i-g-t 0/2] Add support for prehistoric sphinx versions Mauro Carvalho Chehab
2023-03-29 11:19 ` [igt-dev] [PATCH i-g-t 1/2] conf.py: add some backward-compatibility bits Mauro Carvalho Chehab
2023-03-29 11:19 ` Mauro Carvalho Chehab [this message]
2023-03-29 12:10 ` [igt-dev] ✓ Fi.CI.BAT: success for Add support for prehistoric sphinx versions Patchwork
2023-03-29 12:26 ` [igt-dev] [PATCH i-g-t 0/2] " Swati Sharma
2023-03-30  1:34 ` [igt-dev] ✓ Fi.CI.IGT: success for " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230329111954.2584660-3-mauro.chehab@linux.intel.com \
    --to=mauro.chehab@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox