Skip to content

Commit 947a59b

Browse files
committed
[GR-70733] Update GraalPy Build Tools docs.
PullRequest: graalpython/4052
2 parents 09a8832 + 3980381 commit 947a59b

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,7 @@ repos:
3939
types: [text]
4040
files: '\.(java|py|md|c|h|sh)$'
4141
exclude: '^graalpython/lib-python/.*'
42+
- id: check-toml
43+
exclude: '^graalpython/lib-python/.*'
44+
- id: check-added-large-files
45+
- id: check-symlinks

docs/user/Embedding-Build-Tools.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Embedding Build Tools
22

3+
**Note: The GraalPy build tools are being developed as part of the GraalPy Extensions project in a separate [repository](https://github.com/oracle/graalpy-extensions) on GitHub.**
4+
35
The GraalPy **Maven** and **Gradle** plugins provide functionality to manage Python related resources
46
required for embedding Python code in Java-based applications:
57
- *Python application files* provided by the user, for example, Python sources which are part of the project.
68
- *Third-party Python packages* installed by the plugin during the build according to the plugin configuration.
79

810
Apart from physically managing and deploying those files, it is also necessary to make them available in Python at runtime by configuring the **GraalPy Context** in your Java code accordingly.
9-
The [GraalPyResources](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java) API provides factory methods to create a Context preconfigured for accessing Python, embedding relevant resources with a **Virtual Filesystem** or from a dedicated **external directory**.
11+
The [GraalPyResources](https://github.com/oracle/graalpy-extensions/blob/main/org.graalvm.python.embedding/src/main/java/org/graalvm/python/embedding/GraalPyResources.java) API provides factory methods to create a Context preconfigured for accessing Python, embedding relevant resources with a **Virtual Filesystem** or from a dedicated **external directory**.
1012

1113
## Deployment
1214

@@ -26,7 +28,7 @@ User can choose relative Java resources path that will be made accessible in Pyt
2628
by default it is `org.graalvm.python.vfs`. All resources subdirectories with this path are merged during build and mapped to a configurable Virtual Filesystem mount point at the Python side, by default `/graalpy_vfs`.
2729
For example, a Python file with the real filesystem path `${project_resources_directory}/org.graalvm.python.vfs/src/foo/bar.py` will be accessible as `/graalpy_vfs/src/foo/bar.py` in Python.
2830

29-
Use the following [GraalPyResources](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java)
31+
Use the following [GraalPyResources](https://github.com/oracle/graalpy-extensions/blob/main/org.graalvm.python.embedding/src/main/java/org/graalvm/python/embedding/GraalPyResources.java)
3032
factory methods to create GraalPy Context preconfigured for the use of the Virtual Filesystem:
3133
* `GraalPyResources.createContext()`
3234
* `GraalPyResources.contextBuilder()`
@@ -49,16 +51,16 @@ This is also the case of the default virtual filesystem location.
4951
When a resources directory is not a valid Java package name, such as the recommended "GRAALPY-VFS", the resources are not subject to the encapsulation rules and do not require additional module system configuration.*
5052

5153
#### Extracting files from Virtual Filesystem
52-
Normally, Virtual Filesystem resources are loaded like java resources, but there are cases when files need to be accessed
54+
Normally, Virtual Filesystem resources are loaded like java resources, but there are cases when files need to be accessed
5355
outside the Truffle sandbox, e.g. Python C extension files which need to be accessed by the operating system loader.
5456

55-
By default, files which are of type `.so`, `.dylib`, `.pyd`, `.dll`, or `.ttf`, are automatically extracted to a temporary directory
57+
By default, files which are of type `.so`, `.dylib`, `.pyd`, `.dll`, or `.ttf`, are automatically extracted to a temporary directory
5658
in the real filesystem when accessed for the first time and the Virtual Filesystem then delegates to those real files.
5759

5860
The default extract rule can be enhanced using the `VirtualFileSystem$Builder#extractFilter` API.
5961

60-
Alternatively, it is possible to extract all Python resources into a user-defined directory before creating a GraalPy
61-
context, and then configure the context to use that directory. Please refer to the following [GraalPyResources](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java)
62+
Alternatively, it is possible to extract all Python resources into a user-defined directory before creating a GraalPy
63+
context, and then configure the context to use that directory. Please refer to the following [GraalPyResources](https://github.com/oracle/graalpy-extensions/blob/main/org.graalvm.python.embedding/src/main/java/org/graalvm/python/embedding/GraalPyResources.java)
6264
methods for more details:
6365
* `GraalPyResources.extractVirtualFileSystemResources(VirtualFileSystem vfs, Path externalResourcesDirectory)`
6466
* `GraalPyResourcescontextBuilder(Path externalResourcesDirectory)`
@@ -69,12 +71,12 @@ As an alternative to Java resources with the Virtual Filesystem, it is also poss
6971
A user is then responsible for the deployment of such directory.
7072
Python code will access the files directly from the real filesystem.
7173

72-
Use the following [GraalPyResources](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java) factory methods to create GraalPy Context preconfigured for the use of an external directory:
74+
Use the following [GraalPyResources](https://github.com/oracle/graalpy-extensions/blob/main/org.graalvm.python.embedding/src/main/java/org/graalvm/python/embedding/GraalPyResources.java) factory methods to create GraalPy Context preconfigured for the use of an external directory:
7375
* `GraalPyResources.createContextBuilder(Path)`
7476

7577
## Conventions
7678

77-
The factory methods in [GraalPyResources](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java) rely on the following conventions, where the `${root}` is either an external directory, or a Virtual System mount point on the Python side and Java resources directories, such as `${project_resources_directory}/org.graalvm.python.vfs`, on the real filesystem:
79+
The factory methods in [GraalPyResources](https://github.com/oracle/graalpy-extensions/blob/main/org.graalvm.python.embedding/src/main/java/org/graalvm/python/embedding/GraalPyResources.java) rely on the following conventions, where the `${root}` is either an external directory, or a Virtual System mount point on the Python side and Java resources directories, such as `${project_resources_directory}/org.graalvm.python.vfs`, on the real filesystem:
7880
- `${root}/src`: used for Python application files. This directory will be configured as the default search path for Python module files (equivalent to `PYTHONPATH` environment variable).
7981
- `${root}/venv`: used for the Python virtual environment holding installed third-party Python packages.
8082
The Context will be configured as if it is executed from this virtual environment. Notably packages installed in this
@@ -146,7 +148,7 @@ The Python packages and their versions are specified as if used with `pip`:
146148
...
147149
</configuration>
148150
```
149-
151+
150152
- The **resourceDirectory** element can specify the relative [Java resource path](#java-resource-path).
151153
Remember to use `VirtualFileSystem$Builder#resourceDirectory` when configuring the `VirtualFileSystem` in Java.
152154
```xml
@@ -178,11 +180,11 @@ Remember to use the appropriate `GraalPyResources` API to create the Context. Th
178180
```
179181

180182
### Locking Python Packages
181-
To lock the dependency tree of the specified Python packages, execute the GraalPy plugin goal `org.graalvm.python:graalpy-maven-plugin:lock-packages`.
183+
To lock the dependency tree of the specified Python packages, execute the GraalPy plugin goal `org.graalvm.python:graalpy-maven-plugin:lock-packages`.
182184
```bash
183185
$ mvn org.graalvm.python:graalpy-maven-plugin:lock-packages
184186
```
185-
*Note that the action will override the existing lock file.*
187+
*Note that the action will override the existing lock file.*
186188

187189
For a high level description of this feature, please refer to the
188190
[Python Dependency Management for Reproducible Builds](#pythop-dependency-management-for-reproducible-builds) section
@@ -224,7 +226,7 @@ The plugin can be configured in the `graalPy` block:
224226
...
225227
}
226228
```
227-
229+
228230
- The **resourceDirectory** element can specify the relative [Java resource path](#java-resource-path).
229231
Remember to use `VirtualFileSystem$Builder#resourceDirectory` when configuring the `VirtualFileSystem` in Java.
230232
```bash
@@ -271,3 +273,4 @@ in this document.
271273
272274
* [Embedding Graal languages in Java](https://www.graalvm.org/reference-manual/embed-languages/)
273275
* [Permissions for Python Embeddings](Embedding-Permissions.md)
276+
* [GraalPy extensions on GitHub](https://github.com/oracle/graalpy-extensions)

0 commit comments

Comments
 (0)