[pythonscripting] fix native modules on graal 25.0.x (#19622)

* fix native modules

Signed-off-by: Holger Hees <holger.hees@gmail.com>
This commit is contained in:
Holger Hees
2025-11-06 14:18:10 +01:00
committed by GitHub
parent c4c2193f34
commit 6722b8990a
5 changed files with 7 additions and 31 deletions
@@ -92,12 +92,6 @@ Additionally, you can configure the Add-on via a config file `/openhab/services/
#
#org.openhab.automation.pythonscripting:injectionEnabled = 2
# Enables native modules (requires a manually configured venv)
#
# Native modules are sometimes necessary for pip modules which depends on native libraries.
#
#org.openhab.automation.pythonscripting:nativeModules = false
# Enable dependency tracking
#
# Dependency tracking allows your scripts to automatically reload when one of its dependencies is updated.
@@ -145,7 +139,7 @@ VEnv based python runtimes are optional, but needed to provide support for addit
1. Login into [openHAB console](https://www.openhab.org/docs/administration/console.html) and check your current pythonscripting environment by calling `pythonscripting info`<br/><br/>Important values are:
- `GraalVM version: 24.2.1`
- `GraalVM version: 25.0.1`
- `VEnv path: /openhab/userdata/cache/org.openhab.automation.pythonscripting/venv`<br/><br/>![Add-on informations](doc/venv_info.png)
These values are needed during the next step
@@ -154,8 +148,8 @@ These values are needed during the next step
```shell
# The downloaded graalpy-community tar.gz must match your operating system (linux, windows or macos), your architecture (amd64, aarch64) and your "GraalVM version" of openHAB
wget -qO- https://github.com/oracle/graalpython/releases/download/graal-24.2.1/graalpy-community-24.2.1-linux-amd64.tar.gz | gunzip | tar xvf -
cd graalpy-community-24.2.1-linux-amd64/
wget -qO- https://github.com/oracle/graalpython/releases/download/graal-25.0.1/graalpy-community-25.0.1-linux-amd64.tar.gz | gunzip | tar xvf -
cd graalpy-community-25.0.1-linux-amd64/
# The venv target dir must match your "VEnv path" of openHAB
./bin/graalpy -m venv /openhab/userdata/cache/org.openhab.automation.pythonscripting/venv
@@ -164,6 +158,7 @@ These values are needed during the next step
3. Install 'patchelf' which is needed for native module support in graalpy (optional).
```
apt update
apt-get install patchelf
# zypper install patchelf
# yum install patchelf
@@ -15,7 +15,7 @@
<name>openHAB Add-ons :: Bundles :: Automation :: Python Scripting</name>
<properties>
<helperlib.version>1.0.11</helperlib.version>
<helperlib.version>1.0.12</helperlib.version>
</properties>
<dependencies>
@@ -97,7 +97,6 @@ public class PythonScriptEngine extends InvocationInterceptingPythonScriptEngine
private static final String PYTHON_OPTION_EXECUTABLE = "python.Executable";
// private static final String PYTHON_OPTION_PYTHONHOME = "python.PythonHome";
// private static final String PYTHON_OPTION_SYSPREFIX = "python.SysPrefix";
private static final String PYTHON_OPTION_NATIVEMODULES = "python.NativeModules";
private static final String PYTHON_OPTION_ISOLATENATIVEMODULES = "python.IsolateNativeModules";
private static final String PYTHON_OPTION_CACHEDIR = "python.PyCachePrefix";
@@ -217,15 +216,8 @@ public class PythonScriptEngine extends InvocationInterceptingPythonScriptEngine
if (pythonScriptEngineConfiguration.isVEnvEnabled()) {
@SuppressWarnings("null")
String venvExecutable = pythonScriptEngineConfiguration.getVEnvExecutable().toString();
contextConfig = contextConfig.option(PYTHON_OPTION_EXECUTABLE, venvExecutable);
// Path venvPath = this.pythonScriptEngineConfiguration.getVEnvDirectory();
// .option(PYTHON_OPTION_PYTHONHOME, venvPath.toString()) //
// .option(PYTHON_OPTION_SYSPREFIX, venvPath.toString()) //
if (pythonScriptEngineConfiguration.isNativeModulesEnabled()) {
contextConfig = contextConfig.option(PYTHON_OPTION_NATIVEMODULES, Boolean.toString(true)) //
.option(PYTHON_OPTION_ISOLATENATIVEMODULES, Boolean.toString(true));
}
contextConfig.option(PYTHON_OPTION_EXECUTABLE, venvExecutable) //
.option(PYTHON_OPTION_ISOLATENATIVEMODULES, Boolean.toString(true));
}
if (pythonScriptEngineConfiguration.isCachingEnabled()) {
@@ -75,7 +75,6 @@ public class PythonScriptEngineConfiguration {
public boolean dependencyTrackingEnabled = true;
public boolean cachingEnabled = true;
public boolean jythonEmulation = false;
public boolean nativeModules = false;
public String pipModules = "";
}
@@ -208,10 +207,6 @@ public class PythonScriptEngineConfiguration {
return configuration.jythonEmulation;
}
public boolean isNativeModulesEnabled() {
return configuration.nativeModules;
}
public String getPIPModules() {
return configuration.pipModules;
}
@@ -54,12 +54,6 @@
<default></default>
<advanced>true</advanced>
</parameter>
<parameter name="nativeModules" type="boolean" required="false" groupName="system">
<label>Enables native modules (requires a manually configured venv)</label>
<description>Native modules are sometimes necessary for pip modules which depends on native libraries.</description>
<default>false</default>
<advanced>true</advanced>
</parameter>
<parameter name="dependencyTrackingEnabled" type="boolean" required="true" groupName="system">
<label>Enable dependency tracking</label>
<description>Dependency tracking allows your scripts to automatically reload when one of its dependencies is updated.