Setup proper environment variables in all test scripts. If the Libra binaries are in your PYTHON_PATH and LD_LIBRARY_PATH (as they should be if you followed the installation instructions), no additional steps needed. Otherwise, one can add the location of the binaries (and Python modules) to the PYTHON_PATH directly in the script that one wants to execute (this sets up the PYTHON_PATH only locally, just for this job). As an example, the example below shows how to add the locations of the libmmath and libmeigen to the Python path:
cwd = os.getcwd() sys.path.insert(1,cwd+"/../../_build/src/mmath") sys.path.insert(1,cwd+"/../../_build/src/mmath/meigen")
Here, the "cwd" contains the path of the directory in which the current script has been called. For the purposes of these tutorials, the present directory is one of the sub-folders of the "/tests" directory residing in the root of Libra distributive. Thus, the "_build" directory is two levels higher ("/../../"). In the "_build" folder there is a "src" folder created during the configuring and compilation. This "src" directory contains the sub-folders, similar to those present in the original "src" directory that contains only the source code. Each of the sub-directories will (after a successful built) contain the corresponding libraries. These libraries are essentially the Python modules, which can be loaded into Python scripts via the "import" command. So, in our present file system, we use the instructions in the snippet above to make the modules available. Of course, one is free to use absolute paths rather than the relative as in the example above.
Choose a proper prefix for the module names. Since we can run Libra in a Linux-like mode, even if we are on Windows (via WSL), we are more likely to use the "lib" prefix of the imported Libra libraries, for instance:
from libmmath import * from libmeigen import * from liblinalg import *
On the Cygwin, the library prefixes should start with "cyg", for instance:
from cygmmath import * from cygmeigen import * from cyglinalg import *
In any case, many of the presently developed tutorials and examples will automatically determine the OS that is being used and will choose the appropriate prefix. This is done via the following snippet:
import sys if sys.platform=="cygwin": from cyglibra_core import * elif sys.platform=="linux" or sys.platform=="linux2": from liblibra_core import * from libra_py import *