From fd52dc828c4e9b78ccfd4d7cad045d268685c06d Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Fri, 17 Jan 2025 12:03:39 +0100 Subject: [PATCH 1/3] Ensure esbuild can be detected on windows --- panel/io/compile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panel/io/compile.py b/panel/io/compile.py index 2455c560ac..940fc7176e 100644 --- a/panel/io/compile.py +++ b/panel/io/compile.py @@ -65,7 +65,7 @@ def setup_build_dir(build_dir: str | os.PathLike | None = None): def check_cli_tool(tool_name): try: - result = subprocess.run([tool_name, '--version'], capture_output=True) + result = subprocess.run([tool_name, '--version'], capture_output=True, shell=True) if result.returncode == 0: return True else: From 01882b7979bd5ec086a4396cc12496e22d306a3c Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Fri, 17 Jan 2025 13:14:22 +0100 Subject: [PATCH 2/3] Use backoff instead --- panel/io/compile.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/panel/io/compile.py b/panel/io/compile.py index 940fc7176e..8e232243b3 100644 --- a/panel/io/compile.py +++ b/panel/io/compile.py @@ -63,15 +63,18 @@ def setup_build_dir(build_dir: str | os.PathLike | None = None): shutil.rmtree(temp_dir) -def check_cli_tool(tool_name): +def check_cli_tool(tool_name: str) -> bool: try: - result = subprocess.run([tool_name, '--version'], capture_output=True, shell=True) - if result.returncode == 0: - return True - else: - return False + result = subprocess.run([tool_name, '--version'], capture_output=True) + code = result.returncode == 0 except Exception: - return False + code = 1 + if not code: + return True + if sys.platform == 'win32': + tool_name = f'{tool_name}.cmd' + return check_cli_tool(tool_name) + return False def find_module_bundles(module_spec: str) -> dict[pathlib.Path, list[ReactiveESM]]: From 0625e5f431b561522bd8ab0f77a68e8a4bc185f7 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Fri, 17 Jan 2025 16:49:15 +0100 Subject: [PATCH 3/3] Use shutil.which instead --- panel/io/compile.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/panel/io/compile.py b/panel/io/compile.py index 8e232243b3..c04b654c3f 100644 --- a/panel/io/compile.py +++ b/panel/io/compile.py @@ -65,11 +65,10 @@ def setup_build_dir(build_dir: str | os.PathLike | None = None): def check_cli_tool(tool_name: str) -> bool: try: - result = subprocess.run([tool_name, '--version'], capture_output=True) - code = result.returncode == 0 + cmd = shutil.which(tool_name) except Exception: - code = 1 - if not code: + cmd = None + if cmd: return True if sys.platform == 'win32': tool_name = f'{tool_name}.cmd'