Doc changed following changes in python environment management changes.

This commit is contained in:
2026-01-16 20:08:27 +01:00
parent 6ee74aa2af
commit 0931eb2a8e
4 changed files with 33 additions and 4 deletions

View File

@@ -64,7 +64,7 @@ In the example above, the global variable ``$(lfn_activity)``
would be created at the end of the item execution. It would contain the resulting
value of the funcToBeExecuted python function.
**Global variables**
**Lua Interpreter environment setup**
Some global variables have an impact on the ``lua_func`` test item behavior:

View File

@@ -107,10 +107,22 @@ In the example above, the global variable ``$(pfn_function test item)``
would be created at the end of the item execution. It would contain the resulting
value of the funcToBeExecuted python function.
**Global variables**
**Python Interpreter environment setup**
Some global variables have an impact on the ``py_func`` test item behavior:
* ``python_path``: This optional global variable can be used to define
the python executable path. If not defined, the python interpreter is
searched in at the default places in the system.
* ``python_env``: This global variable can be used to define
environment variables for the lua script execution environment.
Only `PATH`, `LUA_PATH`, and `LUA_CPATH` are supported.
.. code-block:: yaml
:caption: example of configuration file: param.yaml
[...]
python_env:
PATH: "/my/path/"
PYTHONPATH: "/my/python/modules/"
[...]

View File

@@ -6,7 +6,7 @@ def icon_prefix():
if not hasattr(prefs, "settings"):
prefs.init()
if isinstance(prefs.settings.icons_theme, int) and 0 <= prefs.settings.icons_theme < len(cst.ICON_THEMES_PREFIX):
if isinstance(prefs.settings.icons_theme, int) and (0 <= prefs.settings.icons_theme < len(cst.ICON_THEMES_PREFIX)):
return cst.ICON_THEMES_PREFIX[prefs.settings.icons_theme]
else:
return cst.ICON_THEMES_PREFIX[0]

View File

@@ -1,3 +1,4 @@
import os
import sys
import shutil
import subprocess
@@ -69,6 +70,22 @@ class PyFuncExecEngine:
if self._process is not None:
raise ETUMRuntimeError("The function subprocess has already been started.")
# POpen config
CUST_ENV = {
"PATH": {"replace": False},
"PYTHONPATH": {"replace": True},
}
py_env = tm.gd("python_env", {})
env = os.environ.copy()
for k, v in CUST_ENV.items():
e = py_env.get(k, "")
if e != "":
if v["replace"]:
env[k] = e
else:
env[k] = e + ";" + env.get(k, "")
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(("localhost", 0))
self._port = sock.getsockname()[1]
@@ -81,7 +98,7 @@ class PyFuncExecEngine:
params.append("-v")
self._process = subprocess.Popen(
params, cwd=func_proc_path
params, env=env, cwd=func_proc_path
)
# Port was reserved until the sub-process is started. Now released.