Commit cb3ec00
committed
Make PythonScriptRunner logic less tightly coupled
Now, if there is any java.util.function.Function named
PythonScriptRunner in the ObjectService, we try to use its apply
function, rather than requiring the runner to be of a special type.
In this way, the scyjava library can gain a new function
enable_python_scripting(context) that injects such a function
(implemented on the Python side via @JImplements, of course, in the same
way that the PythonScriptRunner was with the previous design iteration),
without needing to guard against the possibility that scripting-python
is unavailable at runtime when the @JImplements decorator executes;
the only class needed (Function) is part of the Java standard library.
Python scripts wanting to launch a Java capable of making use of
this PythonScriptEngine should now perform the following steps:
1. Put scripting-python on the classpath, either via the
org.scijava:scripting-python Maven coordinate string in an endpoint,
or locally via scyjava.config.add_classpath;
2. Construct a SciJava context; and
3. Invoke the scyjava.enable_scijava_scripting(context) function.
After which point, using the context's ScriptService to execute Python
scripts should start working! \^_^/1 parent a7550c9 commit cb3ec00
File tree
2 files changed
+36
-67
lines changed- src/main/java/org/scijava/plugins/scripting/python
2 files changed
+36
-67
lines changedLines changed: 36 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
| 42 | + | |
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
| |||
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
48 | | - | |
49 | | - | |
50 | 51 | | |
51 | 52 | | |
52 | | - | |
| 53 | + | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| |||
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
61 | | - | |
| 63 | + | |
62 | 64 | | |
63 | 65 | | |
64 | | - | |
| 66 | + | |
65 | 67 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 68 | + | |
70 | 69 | | |
71 | 70 | | |
72 | 71 | | |
73 | 72 | | |
74 | 73 | | |
75 | 74 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
84 | 87 | | |
85 | 88 | | |
86 | 89 | | |
| |||
105 | 108 | | |
106 | 109 | | |
107 | 110 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
112 | 115 | | |
113 | 116 | | |
114 | 117 | | |
| |||
173 | 176 | | |
174 | 177 | | |
175 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
176 | 191 | | |
Lines changed: 0 additions & 46 deletions
This file was deleted.
0 commit comments