Python for ooRexx is a library to enable ooRexx to interact with Python classes, objects, and functions.
It connects the ooRexx C++ API with the Python/C API.
The idea for this library came from Prof. Dr. Rony G. Flatscher, who is the original author of BSF4ooRexx – a bidirectional bridge between Java and ooRexx.
This library is under active development. Therefore, breaking changes are currently not avoidable.
The ultimate goal is to support Linux, macOS, Windows operating systems, the Python standard library, and Python packages installed with pip. However, the library is currently developed and tested on Windows only, and only the Python standard library is supported at present.
- Windows 10 or later
- ooRexx 5.1.0
- Python 3.12.x
- Python for ooRexx:
PyRexx.cls
,PyRexx.dll
, andpyrexx.py
.
Other versions of Windows, ooRexx and Python 3 might work, but have not been explicitly tested.
The three files required for Python for ooRexx can be downloaded from this repository. PyRexx.dll
was built with Python 3.12.7.
PyRexx.dll
is forward- and backwards-compatible across a minor release of Python.
So, PyRexx.dll
compiled for Python 3.12.7 will work on 3.12.0 and vice versa, but will need to be compiled separately for 3.11.x and 3.13.x.
Backward and forward compatibility will be improved in future releases.
Environment variables
Path: PyRexx.dll
must be able to find the local installation of Python. Therefore, add the installation directory to the Path
environment variable. On a Windows system, the installation directory typically defaults to C:\Users\Username\AppData\Local\Programs\Python\Python312
.
PYTHONPATH: PyRexx.dll
must also be able to find the pyrexx.py
module, which will be located in the same directory. Therefore, create a new environment variablee PYTHONPATH
and set its value to .
(dot).
Files
Optional: If you want to make Python for ooRexx globally available, put PyRexx.cls
, PyRexx.dll
, and pyrexx.py
into your ooRexx installation directory. On a Windows system, the installation directory typically defaults to C:\Program Files\oorexx
. The tutorial below will use a local copy of these files.
Create a new directory and put a copy of PyRexx.cls
, PyRexx.dll
, and pyrexx.py
into it. Create a new file hello.rex
and put the following contents to it:
py = .PyRexx~new()
py~print('hello, world')
::requires 'PyRexx.cls'
To run the example in the command-line, just type:
> rexx hello
This will use Python's built-in function print to display hello, world
on the screen.
A good place to learn about more advanced usage are the unit tests for the Python standard library.
This library has been successfully built with MSYS2 version 20241208.
- Download and install MSYS2.
- In the MSYS2 terminal run the following command:
$ pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
- Clone or download this Git repository.
- Edit
make.cmd
to adjust the variables to your system's settings. - Run
make.cmd
in the Widows command-line.
Python for ooRexx comes with a minimal version of ooRexxUnit.
From the Git repository move the Lib
directory and the PythonXYZ.dll
file to some other place to enable the use of the system's local Python installation.
Unfortunately, due to a yet to be solved bug regarding the Python datetime module, its test group has to be executed seperatly.
To run all other test groups in the command-line, just type:
C:\python-for-oorexx>rexx testOORexx -R test -x datetime.testGroup
To run a specific test group, just type:
C:\python-for-oorexx>rexx testOORexx -R test -f datetime.testGroup