Skip to content

Commit f88fd21

Browse files
committed
added gradle and maven plugin docs
1 parent 2c0e8fc commit f88fd21

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

docs/user/Embedding-Build-Tools.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,27 @@ permalink: /reference-manual/python/Embedding-Build-Tools/
77

88
# Embedding Build Tools
99

10-
The GraalPy Maven and Gradle plugins provide functionality to manage resources required for embedding Python in Java-based applications:
10+
The GraalPy **Maven** and **Gradle** plugins provide functionality to manage resources required for embedding Python in Java-based applications:
1111

1212
This embedding relevant resources can be one of the following:
1313
- Python application files, for example, Python sources which are part of the project.
1414
- Third-party Python packages which can be accessed either from the projects Python sources or from Java.
1515
- The Standard library which is necessary to make a generated native executable self-contained.
1616

1717
Besides physically managing and distributing this files by the plugins, it is also necessary to make them available at runtime by accordingly
18-
configuring the GraalPy context in your Java code. `GraalPyResources.java` TODO - how link to file/javadoc? provides factory methods
19-
to create a **GraalPy context** suitable for accessing Python embedding relevant resources with a **virtual filessystem** or from a dedicated **external directory**.
18+
configuring the GraalPy **context** in your Java code. [GraalPyResources](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/utils/GraalPyResources.java) provides factory methods
19+
to create a context suitable for accessing Python embedding relevant resources with a **virtual filessystem** or from a dedicated **external directory**.
2020

21-
### Virtual filesystem
21+
### Virtual Filesystem
2222

2323
Resource files in a Maven or Gradle project are typically located in dedicated project resource directories, and then distributed in
2424
one application file (JAR or native image).
2525

2626
The GraalPy virtual filesystem can access resource files as standard Java resources and make them available to Python code running in GraalPy so
27-
that it can use standard Python IO to access those files.
27+
that it can use standard Python IO to access those files. In order to make this work, it is necessary for the resource files to have their resource root directory
28+
set to `/org.graalvm.python.vfs` which then becomes the virtual filesystem root and is in python code mapped to the
29+
virtual filesystem mount point, by default `/graalpy_vfs`. For example a python file with the real filesystem path `${project_resources_directory}/org.graalvm.python.vfs/src/foo/bar.py`
30+
will have at runtime the path `/graalpy_vfs/src/foo/bar.py`.
2831

2932
Each kind of the resource files is held in a different project resource directory:
3033
- `${project_resources_directory}/org.graalvm.python.vfs/src` - is used for Python application files. Contents of this directory are not directly managed by the plugin,
@@ -34,13 +37,12 @@ and its contents are generated and managed entirely by the plugin. Any manual ch
3437
- `${project_generated_resources_directory}/org.graalvm.python.vfs/home` - this directory is used for the Standard library
3538
and its contents are generated and managed entirely by the plugin. Any manual changes may be overwritten.
3639

37-
`GraalPyResources.java` provides factory methods to create a GraalPy context with a default or custom virtual filesystem configuration.
38-
For more information on how to configure a virtual filesystem, refer to `VirtualFileSystem.Builder` TODO - how link to file/javadoc?.
40+
[GraalPyResources](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/utils/GraalPyResources.java) provides factory methods to create a GraalPy context with a default or custom virtual filesystem configuration. For more information on how to configure a virtual filesystem, refer to [VirtualFileSystem.Builder](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/utils/VirtualFileSystem.java).
3941

40-
### Resources in an external directory
42+
### Resources in an External Directory
4143

4244
As an alternative to the virtual filesystem, it is also possible to configure the plugin to hold the resource files in an external directory.
43-
`GraalPyResources.java` provides methods to create a GraalPy context preconfigured to work with a dedicated resources directory as long at it has the following structure:
45+
[GraalPyResources](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/utils/GraalPyResources.java) provides methods to create a GraalPy context preconfigured to work with a dedicated resources directory as long at it has the following structure:
4446
- `${resources_directory}/src` - is used for Python application files. Contents of this directory are not directly managed by the plugin,
4547
only added to the final application file (JAR or native image).
4648
- `${resources_directory}/venv` - this directory is used for the Python virtual environment holding third-party Python packages
@@ -52,7 +54,8 @@ Note, that by storing the resource files in an external directory, they are not
5254

5355
### GraalPy Context
5456

55-
Regarding the particular resource paths, a GraalPy context instance created by factory methods in `GraalPyResources` is preconfigured in the following way:
57+
Regarding the particular resource paths, a GraalPy context instance created by factory methods in [GraalPyResources](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/utils/GraalPyResources.java)
58+
is preconfigured in the following way:
5659
- `${resources_root_directory}/home` - is reserved for the GraalPy Standard Library. GraalPy context will be configured to
5760
use this standard library as if set in `PYTHONHOME` environment variable.
5861
- `${resources_root_directory}/venv` - is reserved for a Python virtual environment holding third-party packages.

docs/user/README.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ In order to distribute the resulting application for other systems, follow these
6767

6868
## Gradle
6969

70-
1. Create a Java application with Gradle using the command below and follow the prompts (select a build script language, select a test framework, and so on):
70+
1. Create a Java application with Gradle using the command below and follow the prompts (select the Groovy build script language, select a test framework, and so on):
7171
```bash
7272
gradle init --type java-application \
7373
--project-name interop \
@@ -123,28 +123,21 @@ In order to distribute the resulting application for other systems, follow these
123123
5.1. In _app/build.gradle_:
124124
- add the graalpy-gradle-plugin to the `plugins` section:
125125
```
126-
id "org.graalvm.python"
126+
id "org.graalvm.python" version "24.2.0"
127127
```
128128
129129
- configure the GraalPy Gradle plugin:
130130
```
131131
graalPy {
132-
packages = ["termcolor==2.2"]
132+
packages = ["termcolor==2.2"]
133133
}
134134
```
135135
136-
5.2, In _settings.gradle_, add the following build script configuration.
137-
Note that all buildscript blocks must appear before any plugins blocks.
136+
5.2, In _settings.gradle_, add the following `pluginManagement` configuration.
138137
```
139-
buildscript {
138+
pluginManagement {
140139
repositories {
141-
mavenCentral()
142-
maven {
143-
url "https://repo.gradle.org/gradle/libs-releases/"
144-
}
145-
}
146-
dependencies {
147-
classpath "org.graalvm.python:graalpy-gradle-plugin:24.2.0"
140+
gradlePluginPortal()
148141
}
149142
}
150143
```
@@ -170,7 +163,7 @@ In order to distribute the resulting application for other systems, follow these
170163
}
171164
```
172165
173-
See also [Embedding Build Tools](Embedding-Build-Tools.md#graalpy-gradle-plugin) for more information about the GraalPy Gradle Plugin.
166+
See also [Embedding Build Tools](Embedding-Build-Tools.md) for more information about the GraalPy Gradle Plugin.
174167
175168
## Ant, CMake, Makefile or Other Build Systems Without Direct Support for Maven Dependencies
176169

0 commit comments

Comments
 (0)