|
|
The JPython Registry
Because there is no good platform independent equivalent of the Windows
Registry (or Unix envrionment variables) Java has it's own environment
variable namespace. JPython aquires it's namespace from the following
three sources (later sources override defaults found in earlier
places).
- The Java system properties: typically passed in on the command
line. See the -D option to the
interpreter.
- The JPython "registry" file, which contains
prop=value pairs.
See below for the
algorithm JPython uses to find the registry file.
- The user's personal registry file, which contains
similarly formated prop/value pairs. The user's registry file
is at "user.home"+"/.jpython"
Registry Properties
The following properties are recognized by JPython. There may be
others that aren't documented here; consult the comments in registry
file for details.
- python.path
- Equivalent to CPython's PYTHONPATH environment variable
- python.cachedir
- The directory to use for caches - currently just package
information. This directory must be writable by the user. If the
directory is an absolute path, it is used as given, otherwise it
is interpreted as relative to sys.prefix.
- python.verbose
- Sets the verbosity level for varying degrees of informative
messages. Valid values in order of increasing verbosity are
"error", "warning", "message", "comment", "debug"
- python.security.respectJavaAccessibility
- Normally, JPython can only provide access to public members of
classes. However if this property is set to false and
you are using Java 1.2 then JPython can access non-public
fields, methods, and constructors.
- python.jpythonc.compiler
- The Java compiler to use with the jpythonc tool,
which now generates Java source code. This should be the absolute
path to a Java compiler, or the name of a compiler on your
standard PATH.
- python.jpythonc.classpath
- Extensions to the standard java.class.path property
for use with jpythonc. This is useful if you use Jikes as your
compiler.
- python.jpythonc.compileropts
- Options to pass to the Java compiler when using jpythonc.
The following steps are used to find the JPython registry file, and
also to set the Python values for sys.prefix. First a
root directory is calculated:
- If there is a property called
python.home, this is used as the root directory.
- Otherwise, the property install.root is used if it
exists.
- If neither of those properties exist, then JPython searches
for the file "jpython.jar" on the Java classpath, as defined in
the system property java.class.path. The actual file
system isn't searched, only the paths defined on the classpath
(one of them must literally include "jpython.jar").
Once the root directory is found, sys.prefix and
sys.exec_prefix are set to this, and sys.path has
rootdir/Lib appended to it. The registry file used is then
rootdir/registry.
|