Skip to content

Commit

Permalink
Merge pull request #2331 from lf-lang/python-paths
Browse files Browse the repository at this point in the history
API to look up source and package directory in Python
  • Loading branch information
edwardalee authored Jul 4, 2024
2 parents 4c3e177 + 235cc97 commit d7dbb88
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/resources/lib/c/reactor-c
22 changes: 22 additions & 0 deletions test/Python/src/PythonPaths.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* This tests the functions lf.source_directory() and lf.package_directory(). Success is just
* compiling and running without error. The test prints the contents of this file twice.
*/
target Python

preamble {=
import os
=}

main reactor {
state source_path = {= os.path.join(lf.source_directory(), "PythonPaths.lf") =}
state package_path = {= os.path.join(lf.package_directory(), "src", "PythonPaths.lf") =}

reaction(startup) {=
with open(self.source_path, "r") as file:
print(file.read());
print("----------------");
with open(self.package_path, "r") as file:
print(file.read());
=}
}

0 comments on commit d7dbb88

Please sign in to comment.