Python files are generally located at $CEI_HOME/ensight232/site_preferences/extensions. This directory contains two sub-directories: core and user_defined. The contents of the former are discussed in the next couple of sections. The ‘user_defined’ directory contains the various EnSight extensions that are loaded on startup. A fairly large number of default extensions are included in this directory by default.
When the module ensight.core is imported, it defines a method ‘load_extensions()’ which is called by the ensight ‘C’ startup code. When load_extensions() is invoked, it walks the subdirs in the sys.path names that end with the directory ‘extensions’ (see ‘Startup’ above). If the sub-directory contains a __init__.py file, the subdir is ‘import’ed into the module ensight.ext (note: ensight.ext.__path__ is modified to include the ‘extensions’ directory names).
While EnSight does not support PYTHONPATH, it does support the environmental variable CEI_PYTHONPATH. Setting this environmental variable to a list of directories will cause those directories to be added to sys.path on startup. For example:
export CEI_PYTHONPATH=/tmp:/usr/tmp
set CEI_PYTHONPATH=C:\tmp;C:\Users\Public
will both add two directories to sys.path on Linux and Windows respectively.
The EnSight Product/Package extension system can also be used to extend sys.path. If a product.xml file points to a loading python file that does not load any extensions, it will still add the directory containing the product.xml file to sys.path. For example, a folder containing a 'product.xml' file with the contents:
<?xml version="1.0" encoding="UTF-8"?>
<product>
<ensight_extension>
<loader>dummy.py</loader>
<requires>
<ensight_core>
<minimum>10.0.0.0</minimum>
<maximum>11.0.0.-1</maximum>
</ensight_core>
</requires>
</ensight_extension>
</product>
and the file 'dummy.py' with these contents being placed in the same folder:
#ENSIGHT_USER_DEFINED_BEGIN
#FACTORY=ctor
#ENSIGHT_USER_DEFINED_END
def ctor(parent):
return list()
will cause the folder containing the files in sys.path, without actually installing any extensions. These folders can be located in '.ensightXXX/extensions' directories or $CEI_HOME. The product.xml file can also be used to restrict the folder addition to specific releases of EnSight.
The EnSight Python startup sequence looks like: