-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathpdm_build.py
39 lines (31 loc) · 1.03 KB
/
pdm_build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import json
import shutil
import subprocess
import sysconfig
def pdm_build_initialize(context):
context.ensure_build_dir()
deno_json = context.root / "deno.json"
deno_config = json.loads(deno_json.read_text())
context.config.metadata["version"] = deno_config["version"]
if context.target == "sdist":
return
# Inject compiled binary into scripts/, so it will be picked up to install
target = context.root / "scripts" / "bids-validator-deno"
deno = shutil.which("deno")
if deno is None:
raise OSError("Deno is not installed or not in PATH")
subprocess.run(
[
deno,
"compile",
"-ERNW",
"--allow-run",
"-o",
str(target),
"src/bids-validator.ts",
],
check=True,
)
# Add the current platform tag so the wheel is specific to the OS/architecture
platform_tag = sysconfig.get_platform().replace("-", "_").replace(".", "_")
context.config_settings["--plat-name"] = platform_tag