Skip to content

Commit 719642f

Browse files
Add JACPATH support for module path resolution in ModulePath class
1 parent 8554c4e commit 719642f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

jac/jaclang/compiler/absyntree.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,15 @@ def resolve_relative_path(self, target_item: Optional[str] = None) -> str:
10271027
if os.path.exists(relative_path + ".jac")
10281028
else relative_path
10291029
)
1030+
jacpath = os.getenv("JACPATH")
1031+
if not os.path.exists(relative_path) and jacpath:
1032+
name_to_find = actual_parts[-1] + ".jac"
1033+
1034+
# Walk through the single path in JACPATH
1035+
for root, _, files in os.walk(jacpath):
1036+
if name_to_find in files:
1037+
relative_path = os.path.join(root, name_to_find)
1038+
break
10301039
return relative_path
10311040

10321041
def normalize(self, deep: bool = False) -> bool:

0 commit comments

Comments
 (0)