Startup

Parent Previous Next

EnSight distribution directory structure

Python files are generally located at $CEI_HOME/ensight212/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.

Python binding on startup

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).

CEI_PYTHONPATH

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.

Empty EnSight Extension

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.

Python interpreter startup

The EnSight Python startup sequence looks like:


    1. Set up PYTHON_HOME/PATH
    2. Create up the ‘ensight’ module
    3. Create the cmdlanguage methods in ‘ensight’
    4. import sys, sip, imp
    5. import PyQt4.Gui
    6. Create the parent widget wrapper
    7. Add $CEI_HOME/ensight{version}/site_preferences/extensions to sys.path
    8. If it exists, add $HOME/.ensight{version}/extensions to sys.path
    9. import ensight.core (note: this has the side effect of adding the names specified by CEI_PYTHONPATH to sys.path)
    10. run ensight.core.load_extensions() → loads any user defined extensions and pulls in the language files (*.qm)
    11. Look for directories named: $CEI_HOME/*/product.xml and load the extensions listed in the qualified <loader> clauses