Skip to content

Commit 571199a

Browse files
authored
Merge pull request #12 from adamburkegh/bug2758_jarray
Jython features page and Jython registry page. Deeplink to book for
2 parents 9990fe4 + fcd1eaf commit 571199a

File tree

5 files changed

+125
-1
lines changed

5 files changed

+125
-1
lines changed

_data/book.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
baseurl: https://jython.readthedocs.io/en/latest/
3+
4+
intro:
5+
url: chapter1/
6+
7+
datatypes:
8+
url: chapter2/
9+
10+
integration:
11+
url: chapter10/
12+
13+
database:
14+
url: chapter12/
15+
16+

_data/pydoc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
baseurl: https://docs.python.org/2.7/
2+
3+
liburl: https://docs.python.org/2.7/library/
4+

index.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@ print('Running on Java version: ' + System.getProperty('java.version'))
2828
print('Unix time from Java: ' + str(System.currentTimeMillis()))
2929
```
3030

31-
Ready to get started? Head over to [Downloads](download)
31+
## Getting Started
32+
33+
Ready to get started? Head over to [Downloads](download).
34+
35+
Or you could read a quick overview of [features specific to Jython](jyspecific).
36+
37+
A more detailed introduction and reference can be found in the [Jython Book]({{site.data.book.baseurl}}).
38+
39+
3240

3341
## Who uses Jython?
3442
Jython is embedded in lots of projects. See some from [MVNRepository](https://mvnrepository.com/artifact/org.python/jython-standalone/usages)

jyspecific.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: Jython-Specific Features
3+
---
4+
5+
{% assign book = site.data.book.baseurl %}
6+
{% assign datatypes = book | append: site.data.book.datatypes['url'] %}
7+
{% assign integration = book | append: site.data.book.integration['url'] %}
8+
{% assign database = book | append: site.data.book.database['url'] %}
9+
10+
# Jython-Specific Features
11+
12+
Jython has a number of features which allow easier integration with Java and make use of the rich environment provided by joining the two languages.
13+
14+
15+
## The Jython Registry
16+
17+
Jython works with a [local Jython registry file](registry) to provide a platform independent equivalent to the Windows registry. It combines this with environment variable and command line information at startup.
18+
19+
20+
## Embedding
21+
22+
Java classes can be [embedded in Python scripts]({{integration}}#using-java-within-jython-applications), and Python scripts invoked and inspected [from Java code]({{integration}}#using-jython-within-java-applications).
23+
24+
25+
## Collection and Array support
26+
27+
Jython provides ways to smoothly integrate [Java collections and arrays]({{datatypes}}#jython-specific-collections) with Python data structures.
28+
29+
30+
## Compiling to Java class files
31+
32+
The [`compileall` module]({{site.data.pydoc.liburl}}compileall.html) in Jython produces Java byte code in Java class files from Python code. It otherwise corresponds to the CPython module of the same name. (Earlier versions used a tool called jythonc which was removed fully in Jython 2.5).
33+
34+
35+
## Database interaction
36+
37+
The [zxjdbc module]({{database}}) provides a Pythonesque interface on top of the Java Database Connectivity API (JDBC).
38+
39+

registry.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: Jython Registry
3+
---
4+
5+
# Jython Registry
6+
7+
Because there is no good platform independent equivalent of the Windows Registry (or Unix envrionment variables) Java has it's own environment variable namespace. Jython aquires it's namespace from the following sources (later sources override defaults found in earlier places).
8+
9+
- The Java system properties: typically passed in on the command line as options to the java interpreter.
10+
- The Jython "registry" file, which contains prop=value pairs. See below for the algorithm Jython uses to find the registry file.
11+
- The user's personal registry file, which contains similarly formated prop/value pairs. The user's registry file is at `"user.home"+"/.jython"`
12+
- Jython properties: Specified on the command line as options to the jython class. See the -D option to the interpreter.
13+
14+
## Registry Properties
15+
16+
The following properties are recognized by Jython. More detailed documentation may be found in comments in the `registry` file provided with the Jython distribution.
17+
18+
**python.path**
19+
Equivalent to CPython's `PYTHONPATH` environment variable
20+
21+
**python.cachedir**
22+
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.
23+
24+
**python.verbose**
25+
Sets the verbosity level for varying degrees of informative messages. Valid values in order of increasing verbosity are "error", "warning", "message", "comment", "debug"
26+
27+
**python.security.respectJavaAccessibility**
28+
Normally, Jython can only provide access to public members of classes. If this property is set to false, and you are using a Java version before Java 9, then Jython can access non-public fields, methods, and constructors. This may be deprecated in the future due to Java changes to accessibility from version 9.
29+
30+
**python.console**
31+
The name of a console class. An alternative console class that supports GNU readline can be installed with this property. Jython already include such a console class and it can be enabled by setting this property to `org.python.util.ReadlineConsole`.
32+
33+
**python.console.readlinelib**
34+
Allow a choice of backing implementation for GNU readline support. Can be either GnuReadline or Editline. This property is only used when python.console is set to org.python.util.ReadlineConsole.
35+
36+
**python.startup**
37+
File to be run at the start of each interactive session, but not when dropping in with the -i flag in after a script has run.
38+
39+
**python.modules.builtin**
40+
Add, remove, or override built in modules.
41+
42+
**python.cpython2**
43+
Command used to invoke CPython, when needed, as in the case of modules and methods longer than Java supports natively.
44+
45+
46+
47+
48+
## Finding the Registry File
49+
50+
The following steps are used to find the Jython registry file, and also to set the Python values for `sys.prefix`. First a root directory is calculated:
51+
52+
- If there is a property called `python.home`, this is used as the root directory.
53+
- Otherwise, the property `install.root` is used if it exists.
54+
- If neither of those properties exist, then Jython searches for the file "jython.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 "jython.jar").
55+
56+
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.
57+

0 commit comments

Comments
 (0)