Skip to content

Commit 4bd8b61

Browse files
committed
[GR-52172] Update github readme.
PullRequest: graalpython/3211
2 parents 1a3ab86 + d8df703 commit 4bd8b61

24 files changed

+1651
-1213
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ language runtime. The main focus is on user-observable behavior of the engine.
2727
** creating new script with local maven repo for testing: `jbang init --template=graalpy_local_repo@oracle/graalpython -Dpath_to_local_repo=/absolute/path/to/local/maven/repository myscript.java'
2828

2929
## Version 23.1.0
30-
* Oracle GraalPy distributions (previously known as GraalPy Enterprise) are now available under the [GFTC license](https://www.oracle.com/downloads/licenses/graal-free-license.html). The community builds published on Github have been renamed to `graalpy-community-<version>-<os>-<arch>.tar.gz`.
30+
* GraalPy distributions (previously known as GraalPy Enterprise) are now available under the [GFTC license](https://www.oracle.com/downloads/licenses/graal-free-license.html). The community builds published on Github have been renamed to `graalpy-community-<version>-<os>-<arch>.tar.gz`.
3131
* Add support for the sqlite3 module. This allows many packages like `coverage` or `Flask-SQLAlchemy` to work on top of this embedded database.
3232
* Provide Windows distributions of GraalPy. This is the first preview of Windows support for GraalPy, and there are limitations, but pure Python packages like Pygal can be installed with `python -m pip --no-cache install pygal`.
3333
* The GraalPy standalone tool was updated. You can now build single-file executable Python binaries for Linux, Windows, and macOS. The tool can also generate a skeleton Maven project that sets up a polyglot embedding of Python packages into Java.

README.md

Lines changed: 179 additions & 54 deletions
Large diffs are not rendered by default.

docs/contributor/CONTRIBUTING.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ Please also take some time to review our [code of conduct](http://www.graalvm.or
1111

1212
The first thing you want to do is to set up [`mx`](https://github.com/graalvm/mx.git).
1313
This is the build tool we use to develop GraalVM languages.
14-
Note that you can use any JDK, and do not need GraalVM for development.
15-
In that case you'll only be able to run without the just-in-time compiler, but that can be fine for making and testing changes that are not performance sensitive.
14+
```shell
15+
git clone https://github.com/graalvm/mx.git
16+
```
17+
Make sure to add the `mx` directory to your `PATH`.
18+
19+
You can always use the latest stable JDK for development.
1620
You can also download a suitable JDK using mx:
1721
```bash
1822
mx fetch-jdk
@@ -24,7 +28,7 @@ For building GraalPy, you will also need some native build tools and libraries.
2428
sudo apt install build-essential libc++-12-dev zlib1g-dev cmake
2529
```
2630

27-
Lastly, download maven, extract it and include it on your `PATH`.
31+
Lastly, download maven, extract it and include it on your `PATH`.
2832

2933
Once you have all the necessary tools, you can run `mx build` in this repository.
3034
This will initially download the required dependencies next to the repository and build Python.

docs/showcase.png

299 KB
Loading

docs/user/Embedding-Permissions.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
layout: docs-experimental
3+
toc_group: python
4+
link_title: Embedding Permissions
5+
permalink: /reference-manual/python/Embedding-Permissions/
6+
redirect_from: /reference-manual/python/OSInterface/
7+
---
8+
9+
# Permissions for Python Embeddings
10+
11+
## Access Control and Security Limits for Python Scripts
12+
13+
Embedding GraalPy into Java works with the [GraalVM Polyglot Sandbox](https://www.graalvm.org/latest/reference-manual/embed-languages/#controlling-access-to-host-functions).
14+
15+
## Python's POSIX Interface
16+
17+
The way the operating system interface is exposed to Python scripts is GraalPy-specific.
18+
By default all access is routed through Java interfaces, but some packages rely on details of POSIX APIs and require direct native access.
19+
20+
Graal languages (those implemented on the [Truffle framework](https://www.graalvm.org/latest/graalvm-as-a-platform/language-implementation-framework/)) usually implement system-related functions using the [Truffle abstraction layer](https://github.com/oracle/graal/blob/master/truffle/docs/README.md), which is OS independent and provides extension points for the users when embedding GraalPy or other Graal languages into Java applications.
21+
See, for example, the [Truffle FileSystem service-provider](https://www.graalvm.org/truffle/javadoc/org/graalvm/polyglot/io/FileSystem.html).
22+
23+
The standard Python library also provides an OS abstraction, but exposes lower level interfaces. For example, the `os` module directly exposes some POSIX functions.
24+
On non-POSIX platforms, this interface is emulated to a degree.
25+
26+
GraalPy provides two alternative implementations (each referred to as a "backend") of system-related functionality offered by built-in Python modules such as `os`.
27+
The `PosixModuleBackend` option determines which backend is used: valid values are `native` and `java`.
28+
29+
### Native Backend
30+
31+
This backend directly calls the POSIX API in mostly the same way as CPython (the reference Python implementation).
32+
33+
This approach is the most compatible with CPython and provides bare access to the underlying OS interface without an intermediate emulation layer.
34+
35+
By default, this implementation bypasses the Truffle abstraction layer, and therefore it is not sandboxed and does not support custom implementations of [Truffle FileSystem service-provider](https://www.graalvm.org/truffle/javadoc/org/graalvm/polyglot/io/FileSystem.html), and other Polyglot API providers related to system interfaces.
36+
37+
The native backend is chosen by default when GraalPy is started via the `graalpy` or any other Python related launcher.
38+
The exceptions are Python related launchers with `-managed` suffix available only in Oracle GraalVM (for example, `graalpy-managed`), which by default use the `java` POSIX backend.
39+
40+
#### Limitations of the Native Backend
41+
42+
Known limitations are:
43+
44+
* `os.fork` is not supported
45+
* `_posixsubprocess.fork_exec` does not support the `preexec_fn` parameter
46+
47+
### Java Backend
48+
49+
This backend uses the [Truffle abstraction layer](https://github.com/oracle/graal/blob/master/truffle/docs/README.md) and therefore supports custom Polyglot API providers related to system interfaces and sandboxing.
50+
Because this abstraction is POSIX agnostic, it does not expose all the necessary functionality. Some functionality is emulated, and some functionality is unsupported.
51+
52+
The Java backend is the default when GraalPy is run via the `Context` API, that is, [embedded in Java applications](https://github.com/oracle/graal/blob/master/docs/reference-manual/embedding/embed-languages.md), or when it is launched using Python-related launchers with the `-managed` suffix (available only in Oracle GraalVM).
53+
54+
#### Limitations of the Java Backend
55+
56+
GraalPy can log information about known incompatibility of functions executed at runtime, which includes the OS interface-related functions.
57+
To turn on this logging, use the command-line option `--log.python.compatibility.level=FINE` (or other desired logging level).
58+
59+
Known limitations of the of the Java backend are:
60+
61+
* Its state is disconnected from the actual OS state, which applies especially to:
62+
* *file descriptors*: Python-level file descriptors are not usable in native code.
63+
* *current working directory*: is initialized to the current working
64+
directory at the startup, but is then maintained separately. So, for example, `chdir` in Python
65+
does not change the actual current working directory of the process.
66+
* *umask*: has the same limitation as that of the current working directory, but it is always initialized
67+
to `0022` regardless of the actual system value at startup.
68+
* Resolution of file access/modification times depends on the JDK.
69+
The best the Java backend can guarantee is seconds resolution.
70+
* `os.access` and any other functionality based on `faccessat` POSIX function does not support:
71+
* effective IDs.
72+
* `follow_symlinks=False` unless the mode is only `F_OK`.
73+
74+
## Python Native Extensions
75+
76+
Python native extensions run by default as native binaries, with full access to the underlying system.

docs/user/FAQ.md

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)