Skip to content

Commit bd2f497

Browse files
committed
[GR-64014] Improve Maven/Gradle plugin docs, update GraalPy version in README.md.
PullRequest: graalpython/3746
2 parents 64d0c5a + 2b139d3 commit bd2f497

File tree

2 files changed

+62
-55
lines changed

2 files changed

+62
-55
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,20 @@ Refer to our [embedding documentation](https://www.graalvm.org/latest/reference-
5454
<dependency>
5555
<groupId>org.graalvm.polyglot</groupId>
5656
<artifactId>polyglot</artifactId>
57-
<version>24.1.2</version>
57+
<version>24.2.0</version>
5858
</dependency>
5959
<dependency>
6060
<groupId>org.graalvm.polyglot</groupId>
6161
<artifactId>python</artifactId>
62-
<version>24.1.2</version>
62+
<version>24.2.0</version>
6363
<type>pom</type>
6464
</dependency>
6565
```
6666

6767
* Gradle
6868
```kotlin
69-
implementation("org.graalvm.polyglot:polyglot:24.1.2")
70-
implementation("org.graalvm.polyglot:python:24.1.2")
69+
implementation("org.graalvm.polyglot:polyglot:24.2.0")
70+
implementation("org.graalvm.polyglot:python:24.2.0")
7171
```
7272

7373
</details>
@@ -85,12 +85,12 @@ Thanks to our integration with GraalVM Native Image, we can deploy Python applic
8585
* Linux
8686

8787
The easiest way to install GraalPy on Linux is to use [Pyenv](https://github.com/pyenv/pyenv) (the Python version manager).
88-
To install version 24.1.2 using Pyenv, run the following commands:
88+
To install version 24.2.0 using Pyenv, run the following commands:
8989
```bash
90-
pyenv install graalpy-24.1.2
90+
pyenv install graalpy-24.2.0
9191
```
9292
```bash
93-
pyenv shell graalpy-24.1.2
93+
pyenv shell graalpy-24.2.0
9494
```
9595
> NOTE: There will be a delay between GraalPy release and its availability on Pyenv. Make sure to update Pyenv.
9696
@@ -102,12 +102,12 @@ Thanks to our integration with GraalVM Native Image, we can deploy Python applic
102102
* macOS
103103

104104
The easiest way to install GraalPy on macOS is to use [Pyenv](https://github.com/pyenv/pyenv) (the Python version manager).
105-
To install version 24.1.2 using Pyenv, run the following commands:
105+
To install version 24.2.0 using Pyenv, run the following commands:
106106
```bash
107-
pyenv install graalpy-24.1.2
107+
pyenv install graalpy-24.2.0
108108
```
109109
```bash
110-
pyenv shell graalpy-24.1.2
110+
pyenv shell graalpy-24.2.0
111111
```
112112
> NOTE: There will be a delay between GraalPy release and its availability on Pyenv. Make sure to update Pyenv.
113113
@@ -120,20 +120,20 @@ Thanks to our integration with GraalVM Native Image, we can deploy Python applic
120120
```
121121
For example:
122122
```bash
123-
sudo xattr -r -d com.apple.quarantine ~/.pyenv/versions/graalpy-24.1.2
123+
sudo xattr -r -d com.apple.quarantine ~/.pyenv/versions/graalpy-24.2.0
124124
```
125125
3. Uncompress the file and update your `PATH` environment variable to include to the _graalpy-XX.Y.Z-macos-amd64/bin_ (or _graalpy-XX.Y.Z-macos-aarch64/bin_) directory.
126126

127127
* Windows
128128

129129
The Windows support of GraalPy is still experimental, so not all features and packages may be available.
130130
The easiest way to install GraalPy on Windows is to use [Pyenv-win](https://pyenv-win.github.io/pyenv-win/) (the Python version manager for Windows).
131-
To install version 24.1.2 using Pyenv-win, run the following commands:
131+
To install version 24.2.0 using Pyenv-win, run the following commands:
132132
```cmd
133-
pyenv install graalpy-24.1.2-windows-amd64
133+
pyenv install graalpy-24.2.0-windows-amd64
134134
```
135135
```cmd
136-
pyenv shell graalpy-24.1.2-windows-amd64
136+
pyenv shell graalpy-24.2.0-windows-amd64
137137
```
138138
> NOTE: There will be a delay between GraalPy release and its availability on Pyenv. Make sure to update Pyenv.
139139

@@ -152,7 +152,7 @@ The _setup-python_ action supports GraalPy:
152152
- name: Setup GraalPy
153153
uses: actions/setup-python@v5
154154
with:
155-
python-version: graalpy # or graalpy24.1 to pin a version
155+
python-version: graalpy # or graalpy24.2 to pin a version
156156
```
157157

158158
</details>
@@ -179,7 +179,7 @@ To run Jython scripts, you need to use a GraalPy distribution running on the JVM
179179
```
180180
For example:
181181
```bash
182-
sudo xattr -r -d com.apple.quarantine ~/.pyenv/versions/graalpy-24.1.2
182+
sudo xattr -r -d com.apple.quarantine ~/.pyenv/versions/graalpy-24.2.0
183183
```
184184
3. Uncompress the file and update your `PATH` environment variable to include to the _graalpy-jvm-XX.Y.Z-macos-amd64/bin_ (or _graalpy-jvm-XX.Y.Z-macos-aarch64/bin_) directory.
185185
4. Run your scripts with `graalpy --python.EmulateJython`.

docs/user/Embedding-Build-Tools.md

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -90,29 +90,34 @@ To manage third-party Python packages, a [Python virtual environment](https://do
9090
Whether deployed in a virtual filesystem or an external directory, its contents are managed by the plugin based on the Python packages
9191
specified in the plugin configuration.
9292

93-
## Python Dependency Management
93+
## Python Dependency Management for Reproducible Builds
9494

95-
The list of third-party Python packages to be downloaded and installed can be specified in Maven or Gradle plugin configuration. Unfortunately,
96-
Python does not enforce strict versioning of dependencies, which can result in problems if a third-party package or one of its transitive
97-
dependencies is unexpectedly updated to a newer version, leading to unforeseen behavior.
98-
99-
It is regarded as good practice to always specify a Python package with its exact version. In simpler scenarios, where only a few packages
100-
are required, specifying the exact version of each package in the plugin configuration,
101-
along with their transitive dependencies, might be sufficient. However, this method is often impractical,
102-
as manually managing the entire dependency tree can quickly become overwhelming.
95+
In Python ecosystem, it is common that packages specify their dependencies as ranges rather than a fixed version.
96+
For example, package A depends on package B of any version higher or equal to 2.0.0 (denoted as `B>=2.0.0`).
97+
Installation of package A today may pull package `B==2.0.0`. Tomorrow package B releases new version `2.0.1`
98+
and a clean build of a project depending on A will pull new version of B, which may not be compatible
99+
with GraalPy or may introduce (unintentional) breaking changes.
103100

104101
### Locking Dependencies
105102

106-
For these cases, we **highly recommend locking** all Python dependencies whenever there is a change
107-
in the list of required packages for a project. The GraalPy plugins provide an action to do so,
108-
and as a result, a GraalPy lock file will be created, listing all required Python packages with their specific versions
109-
based on the packages defined in the plugin configuration and their dependencies. Subsequent GraalPy plugin executions
110-
will then use this file exclusively to install all packages with guaranteed versions.
103+
We **highly recommend locking** all Python dependencies whenever there is a change in the list of required packages
104+
for a project. Locking the dependencies means explicitly invoking a Maven goal or Gradle task that generates file
105+
`graalpy.lock` that captures versions of all Python package dependencies: those specified explicitly in
106+
`pom.xml` or `build.gradle` and all their transitive dependencies.
107+
108+
The `graalpy.lock` file should be commited to version control system (e.g., git). Once the `graalpy.lock` file exists,
109+
the package installation during Maven or Gradle build installs the exact same versions as captured in `graalpy.lock`.
111110

112-
The default location of the lock file is in the project root, and since it serves as input for generating resources,
113-
it should be stored alongside other project files in a version control system.
111+
When the set of explicit dependencies in `pom.xml` or `build.gradle` changes and does not match what is in
112+
`graalpy.lock` anymore, the build will fail and the user will be asked to explicitly regenerate the `graalpy.lock` file.
114113

115-
For information on the specific Maven or Gradle lock packages actions, please refer to the plugin descriptions below in this document.
114+
Note that unless specific version of a package is desired, we recommend to specify explicit dependencies in
115+
`pom.xml` or `build.gradle` without version quantifier. For some well known packages, GraalPy automatically
116+
installs the version that is known to be compatible with GraalPy. However, once installed, the versions should be
117+
locked to ensure reproducible builds.
118+
119+
For information on the specific Maven or Gradle lock packages actions, please refer to the
120+
Locking Python Packages subsections below.
116121

117122
## GraalPy Maven Plugin
118123

@@ -141,14 +146,6 @@ The Python packages and their versions are specified as if used with `pip`:
141146
...
142147
</configuration>
143148
```
144-
- The **graalPyLockFile** element can specify an alternative path to a GraalPy lock file.
145-
Default value is `${basedir}/graalpy.lock`.
146-
```xml
147-
<configuration>
148-
<graalPyLockFile>${basedir}/graalpy.lock</graalPyLockFile>
149-
...
150-
</configuration>
151-
```
152149

153150
- The **resourceDirectory** element can specify the relative [Java resource path](#java-resource-path).
154151
Remember to use `VirtualFileSystem$Builder#resourceDirectory` when configuring the `VirtualFileSystem` in Java.
@@ -172,9 +169,19 @@ $ mvn org.graalvm.python:graalpy-maven-plugin:lock-packages
172169
```
173170
*Note that the action will override the existing lock file.*
174171

175-
For more information on managing Python packages, please refer to the descriptions of
176-
the `graalPyLockFile` and `packages` fields in the [plugin configuration](#maven-plugin-configuration), as well as the [Python Dependency Management](#python-dependency-management) section
177-
above in this document.
172+
For a high level description of this feature, please refer to the
173+
[Python Dependency Management for Reproducible Builds](#pythop-dependency-management-for-reproducible-builds) section
174+
in this document.
175+
176+
* The **graalPyLockFile** element can change the default path to the GraalPy lock file. Default value is `${basedir}/graalpy.lock`.
177+
The **graalPyLockFile** element by itself will not trigger the locking. The locking must be done by explicitly executing the
178+
`org.graalvm.python:graalpy-maven-plugin:lock-packages` goal.
179+
```xml
180+
<configuration>
181+
<graalPyLockFile>${basedir}/graalpy.lock</graalPyLockFile>
182+
...
183+
</configuration>
184+
```
178185

179186
## GraalPy Gradle Plugin
180187

@@ -202,15 +209,6 @@ The plugin can be configured in the `graalPy` block:
202209
...
203210
}
204211
```
205-
206-
- The **graalPyLockFile** element can specify an alternative path to a GraalPy lock file.
207-
Default value is `$rootDir/graalpy.lock`.
208-
```bash
209-
graalPy {
210-
graalPyLockFile = file("$rootDir/graalpy.lock")
211-
...
212-
}
213-
```
214212

215213
- The **resourceDirectory** element can specify the relative [Java resource path](#java-resource-path).
216214
Remember to use `VirtualFileSystem$Builder#resourceDirectory` when configuring the `VirtualFileSystem` in Java.
@@ -241,10 +239,19 @@ gradle graalPyLockPackages
241239
```
242240
*Note that the action will override the existing lock file.*
243241

244-
For more information on managing Python packages, please refer to the descriptions of
245-
the `graalPyLockFile` and `packages` fields in the [plugin configuration](#gradle-plugin-configuration), as well as the [Python Dependency Management](#python-dependency-management) sections
242+
For a high level description of this feature, please refer to the
243+
[Python Dependency Management for Reproducible Builds](#pythop-dependency-management-for-reproducible-builds) section
246244
in this document.
247245

246+
* The **graalPyLockFile** element can change the default path to the GraalPy lock file. Default value is `${basedir}/graalpy.lock`.
247+
The **graalPyLockFile** element by itself will not trigger the locking. The locking must be done by explicitly executing the
248+
`graalPyLockPackages` task.
249+
```
250+
graalPy {
251+
graalPyLockFile = file("$rootDir/graalpy.lock")
252+
...
253+
}
254+
248255
## Related Documentation
249256
250257
* [Embedding Graal languages in Java](https://www.graalvm.org/reference-manual/embed-languages/)

0 commit comments

Comments
 (0)