Skip to content

Commit 2c58a67

Browse files
committed
try using shutil.which
1 parent a8fc2cc commit 2c58a67

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

pdm_build.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import shutil
12
import subprocess
23
import sysconfig
34

@@ -10,21 +11,22 @@ def pdm_build_initialize(context):
1011
context.ensure_build_dir()
1112
target = context.root / "scripts" / "bids-validator-deno"
1213

13-
try:
14-
subprocess.run(
15-
[
16-
"deno",
17-
"compile",
18-
"-ERNW",
19-
"--allow-run",
20-
"-o",
21-
str(target),
22-
"src/bids-validator.ts",
23-
],
24-
check=True,
25-
)
26-
except FileNotFoundError:
14+
deno = shutil.which("deno")
15+
if deno is None:
2716
raise OSError("Deno is not installed or not in PATH")
2817

18+
subprocess.run(
19+
[
20+
deno,
21+
"compile",
22+
"-ERNW",
23+
"--allow-run",
24+
"-o",
25+
str(target),
26+
"src/bids-validator.ts",
27+
],
28+
check=True,
29+
)
30+
2931
platform_tag = sysconfig.get_platform().replace("-", "_").replace(".", "_")
3032
context.config_settings["--plat-name"] = platform_tag

0 commit comments

Comments
 (0)