-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathProxyCompiler.java
More file actions
34 lines (28 loc) · 1.11 KB
/
ProxyCompiler.java
File metadata and controls
34 lines (28 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package org.python.util;
import java.util.Properties;
import org.python.core.PySystemState;
import org.python.core.RegistryKey;
public class ProxyCompiler {
/**
* Compiles the python file by loading it
*
* FIXME: this is quite hackish right now. It basically starts a whole interpreter and sets
* proxyDebugDirectory as the destination for the compiled proxy class
*
* @param filename python filename to exec
* @param destDir destination directory for the proxy classes
*/
public static void compile(String filename, String destDir) {
Properties props = new Properties(System.getProperties());
props.setProperty(RegistryKey.PYTHON_CACHEDIR_SKIP, "true");
PySystemState.initialize(props, null);
PythonInterpreter interp = new PythonInterpreter();
String origProxyDir = org.python.core.Options.proxyDebugDirectory;
try {
org.python.core.Options.proxyDebugDirectory = destDir;
interp.execfile(filename);
} finally {
org.python.core.Options.proxyDebugDirectory = origProxyDir;
}
}
}