Skip to content

Commit 73e6418

Browse files
committed
fix linkml not available during build
1 parent 0d49f4a commit 73e6418

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

build.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,25 @@
33
import os
44
import subprocess
55
import sys
6+
from linkml.generators.shaclgen import ShaclGenerator
7+
import linkml._version as linkml_version
68

79

810
def convert_to_shacl(input_file: str, output_file: str):
9-
# Construct the command
10-
command = [
11-
"linkml", "generate", "shacl",
12-
"--include-annotations", "--non-closed",
13-
input_file
14-
]
15-
16-
result = subprocess.run(command, capture_output=True, check=True)
11+
# Generate shacl
12+
shacl_shapes = ShaclGenerator(input_file).serialize()
1713

1814
comment = (
19-
f"# This SHACL file was generated using the LinkML\n"
15+
f"# This SHACL file was auto-generated with LinkML {linkml_version.__version__}.\n"
16+
f"#Changes will be overwritten on install.\n"
2017
f"# Source file: {input_file}\n"
21-
f"# Command: {' '.join(command)}\n\n"
18+
"\n"
2219
)
2320

2421
# Run the command and redirect output to the output file
2522
with open(output_file, "w") as outfile:
2623
outfile.write(comment)
27-
outfile.write(str(result.stdout.decode("utf-8")))
24+
outfile.write(shacl_shapes)
2825

2926

3027
def convert_folder_recursively(path: str, force: bool = False):

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pytest-xdist = "^3.6.1"
5151
max-line-length = 120
5252

5353
[build-system]
54-
requires = ["poetry-core"]
54+
requires = ["poetry-core", "linkml"]
5555
build-backend = "poetry.core.masonry.api"
5656

5757
[tool.poetry.build]

0 commit comments

Comments
 (0)