-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2331 from lf-lang/python-paths
API to look up source and package directory in Python
- Loading branch information
Showing
2 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
Submodule reactor-c
updated
2 files
+16 −0 | python/include/pythontarget.h | |
+29 −6 | python/lib/pythontarget.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
=} | ||
} |