Skip to main content

Hi, 

I'm looking to find out if it's possible to install a python module in UV. We are currently running UV 11.3.4 with Python 3.9 embedded.

We've had a request from our development if pytest can be added to what we currently have installed?

Has anyone had any experience installing this module, and were there any adverse consequences that effected Python as a whole?

Thanks,

John Koonce

Hi, 

I'm looking to find out if it's possible to install a python module in UV. We are currently running UV 11.3.4 with Python 3.9 embedded.

We've had a request from our development if pytest can be added to what we currently have installed?

Has anyone had any experience installing this module, and were there any adverse consequences that effected Python as a whole?

Thanks,

John Koonce

John,

You can add module search paths using the .pth file(s) - see below.

You can also explicitly enumerate the module searct path using

import sys
import pprint

pprint.pprint(sys.path)


Worth reviewing again:

For the u2py extension module to be loadable in Python, the u2.pth file is placed in specific directories under the bundled Python installation directory.

The following platforms and their associated paths are available for UniVerse:

Platform Path
AIX $UVHOME/python/lib/python#.#/site-packages
Linux $UVHOME/python/lib/python#.#/site-packages
Windows $UVHOMEpython

The full path of $UVBIN is listed in the u2.pth file so that Python will load it into its search path when starting up. The XDEMO's PP directory path is included in the u2.pth file.

Do not add any custom paths to the u2.pth file because this file is overwritten on upgrades.

To add your directories containing Python modules to the module search path, place a unique path configuration file with the .pth extension in the appropriate path for your database and platform.

Each path needed is included on a separate line in the custom .pth files.

For example, on UniVerse and Windows in the $UVHOMEpython directory with a file called myprograms.pth, the paths will look like:

c:U2AccountsSALESPP
c:U2AccountsRENTALSPP

The custom .pth files are not modified on upgrades.

Remember: Directory paths and the .pth extensions are case-sensitive on Linux and AIX platforms.


My understanding though is that pytest is a Python command line program to test python - is that correct? If so then you can run it free-standing to invoke Python code that calls UniBerse functions, though not to call pytest from UniVerse itself unless pytest can itself be configured as a module. See the .pth file section of the UnIVerse Python documentation.

Regards

JJ


Hi, 

I'm looking to find out if it's possible to install a python module in UV. We are currently running UV 11.3.4 with Python 3.9 embedded.

We've had a request from our development if pytest can be added to what we currently have installed?

Has anyone had any experience installing this module, and were there any adverse consequences that effected Python as a whole?

Thanks,

John Koonce

John,

Yes, you can pip install pytest into the version of Python that is shipped with UniVerse.

While pip  should work from the command line, assuming the PATH is set up to use the version of Python shipped with UniVerse, yet I tend to use python -m.

i.e. 

U2UVpythonpython.exe -m pip install {module name}

Note that I have not played with the pytest module, and leave it to those who may have actually tried it, to respond about any issues.

For Python as a whole: Some modules make changes to the environment when importing, and cause problem if your MV/Python process re-enters the Python program after going back to TCL, it could throw some errors, since the reinitializing of the python environment done by MV can not revert these low level changes to the active process.   To get around this you will need to turn off REINIT.PYTHON.  ( > REINIT.PYTHON OFF )

This is not needed if you enter Python first, and then access MV, since you would end the process each time, and start a new one, removing the need to have to worry about reinitializing.  I am thinking that this may be how your developers are looking at using pytest since it does unit tests for the python module.