Skip to content

Commit bcdefec

Browse files
timfelmsimacek
authored andcommitted
Minor docs update
1 parent 7dc0a58 commit bcdefec

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

docs/user/Embedding-Permissions.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ Known limitations of the Java backend are:
7373

7474
## Python Native Extensions
7575

76-
Python native extensions run by default as native binaries, with full access to the underlying system. See [Embedding limitations](Native-Extensions.md#embedding-limitations)
76+
Python native extensions run by default as native binaries, with full access to the underlying system.
77+
See [Embedding limitations](Native-Extensions.md#embedding-limitations)
7778

7879
The context permissions needed to run native extensions are:
7980
```

docs/user/Native-Extensions.md

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,20 @@ permalink: /reference-manual/python/Native-Extensions/
77

88
# Native Extensions Support
99

10-
Python provides a native extensions API for writing Python extensions in C/C++. GraalPy's support for native extensions
11-
is currently considered experimental, although many packages like NumPy and PyTorch work well for many use cases.
12-
Native extensions built for CPython are not binary compatible with GraalPy, therefore it is not possible to use packages
13-
installed with CPython from GraalPy. Packages have to be installed with GraalPy. Likewise, prebuilt wheels for CPython
14-
from pypi.org cannot be used with GraalPy.
15-
The version of *pip* shipped with GraalPy applies additional patches to packages upon installation to make native
16-
extensions work, it is therefore crucial that you only use the *pip* preinstalled in GraalPy virtualenvs to install
17-
packages. Don't update *pip* or use alternative tools such as *uv*. GraalPy's *pip* is also preconfigured to use an
18-
extra repository from graalvm.org where we plan to publish prebuilt wheels for GraalPy for selected commonly used
19-
packages.
10+
CPython provides a [native extensions API](https://docs.python.org/3/c-api/index.html) for writing Python extensions in C/C++.
11+
GraalPy provides experimental support for this API, which allows many packages like NumPy and PyTorch to work well for many use cases.
12+
The support extends only to the API, not the binary interface (ABI), so extensions built for CPython are not binary compatible with GraalPy.
13+
Packages that use the native API have to be built and installed with GraalPy, and the prebuilt wheels for CPython from pypi.org cannot be used.
14+
For best results it is crucial that you only use the `pip` command that comes preinstalled in GraalPy virtualenvs to install packages.
15+
The version of `pip` shipped with GraalPy applies additional patches to packages upon installation to fix known compatibility issues and it is preconfigured to use an additional repository from graalvm.org where we publish a selection of prebuilt wheels for GraalPy.
16+
Do not update `pip` or use alternative tools such as `uv`.
2017

2118
## Embedding limitations
2219

2320
Python native extensions run by default as native binaries, with full access to the underlying system.
24-
Native code is not sandboxed and can circumvent any protections Truffle or the JVM may provide, up to and including
25-
aborting the process.
26-
Native data structures are not subject to the Java GC and the combination of them with Java data structures may lead to
27-
memory leaks.
28-
Native libraries generally cannot be loaded multiple times into the same process, and they may contain global state that
29-
cannot be safely reset. Thus, it's not possible to create multiple GraalPy contexts that access native modules within
30-
the same JVM. This includes the case when you create a context, close it and then create another context. The second
31-
context will not be able to access native extensions.
21+
Native code is not sandboxed and can circumvent any protections Truffle or the JVM may provide, up to and including aborting the entire process.
22+
Native data structures are not subject to the Java GC and the combination of them with Java data structures may lead to memory leaks.
23+
Native libraries generally cannot be loaded multiple times into the same process, and they may contain global state that cannot be safely reset.
24+
Thus, it's not possible to create multiple GraalPy contexts that access native modules within the same JVM.
25+
This includes the case when you create a context, close it and then create another context.
26+
The second context will not be able to access native extensions.

0 commit comments

Comments
 (0)