Prerequisites
- Prerequisite: The GAUSS Engine must first be installed. The default paths will be
C:\mteng19
for Windows and~/mteng19
for non-Windows installations. - You must have a g.gkf file, normally provided by Aptech Systems when a license is acquired. Please contact us if you need this. This file is what will allow a third-party user to run your GAUSS code without using your own license.
- This assumes you also have the Python package built from the gsoop project. The topics mentioned on this page were tested with Python 3.6 on Windows
Files
The following sub-sections show the contents of the files we'll be dealing with.
Scripts
redist.txt lists the minimum required GAUSS dependencies for redistribution.
cityhash.dll
g.gkf
gauss.cfg
gauss.dll
gla.dll
hdf5.dll
iconv.dll
icudt57.dll
icuin57.dll
icuuc57.dll
libiomp5md.dll
libxl.dll
mtengrt.dll
pthreadVC2.dll
readstat.dll
szip.dll
tbb.dll
xls.dll
zlib.dll
gsgraphics_stubs.dll
cql_stubs.dll
redist.bat is a simple script for copying the specified files into a new directory for staging purposes.
@echo off
if "%~1"=="" (
echo Please provide target directory
exit /b 1
)
IF EXIST "%1\gauss.exe" (
echo Target directory cannot be GAUSS installation directory
exit /b 1
)
IF EXIST "%1" (
echo Directory %1 exists, continuing...
) ELSE (
echo Creating directory %1
mkdir "%1"
)
IF NOT EXIST "redist.txt" (
echo File redist.txt is missing. Cannot continue
)
for /f "tokens=* delims=" %%a in ('type redist.txt') do xcopy /hrkvy "%%a" "%1"
ren "%1\gsgraphics_stubs.dll" "gsgraphics.dll"
ren "%1\cql_stubs.dll" "cql.dll"
echo Copied all files
GAUSS code
The GAUSS file must predeclare any symbols that we will be modifying through Python. They can be declared with the declare
keyword as shown, or through a simple assignment call (x = 0
) if you wish to have default values for them.
// these symbols must be declared in order to modify them from Python.
// they don't have to match the proc arg names
declare matrix x,y,ans;
proc (1) = myProc(x, y);
retp(x*y);
endp;
Python code
The Python module we are using for this testing scenario. This specific implementation assumes that the MTENGHOME environment variable home is set. Two other initialization options are shown here if desired.
import sys
import os
from gert import GAUSS, GEMatrix
eng = GAUSS(os.getcwd())
# You can also specify the path manually
#eng = ge.GAUSS("C:/mteng19", False)
# Even using a custom environment variable
#eng = ge.GAUSS("CUSTOM_ENV_VAR")
# Initialize the engine
if not eng.initialize():
sys.exit(1)
# make proc available
eng.executeCompiledFile("myproc.gss.gcg")
# Load variables into workspace
eng["x"] = GEMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 5, 2) # specify rows/cols or else it will save as a vector
eng["y"] = 5
# Call the proc
eng.executeString("ans = myProc(x, y)");
# You could specify the scalar directly as well
#eng.executeString("ans = myProc(x, {})".format(5));
# Fetch answer from workspace
ans = eng["ans"]
# Or fetch & clear value from workspace
#ans = eng.getMatrixAndClear("ans")
print("Answer = \n{}".format(str(ans)))
eng.shutdown()
Stage files
Unzip the redist.zip file into your GAUSS installation directory.
Set Environment Variables
Set up the paths you'd like to use for the rest of the commands, including adding Python to your system PATH.
C:\>set PATH=C:\Python36;%PATH%
C:\>set DESTDIR=C:\development\GEPythonProject
C:\>set MTENGHOME=C:\mteng19
Compile myproc.gss
C:\mteng19>gc.exe myproc.gss
Copy files
C:\mteng19>redist.bat %DESTDIR%
C:\mteng19>xcopy myproc.gss.gcg %DESTDIR%
C:\mteng19>xcopy test_proc.py %DESTDIR%
Your directory structure should look like this now:
C:\ └── development\ └── GEPythonProject\ ├── cityhash.dll ├── cql.dll ├── cql_stubs.dll ├── gauss.cfg ├── gauss.dll ├── g.gkf ├── gla.dll ├── gsgraphics.dll ├── gsgraphics_stubs.dll ├── hdf5.dll ├── iconv.dll ├── icudt57.dll ├── icuin57.dll ├── icuuc57.dll ├── libiomp5md.dll ├── libxl.dll ├── mtengrt.dll ├── myproc.gss.gcg ├── pthreadVC2.dll ├── readstat.dll ├── szip.dll ├── tbb.dll ├── test_proc.py ├── xls.dll └── zlib.dll
Install Python GE/GERT package
C:\mteng19>python.exe -m easy_install ge-0.3.1-py3.6-win-amd64.egg
Test final directory and Python file
C:\mteng19>chdir %DESTDIR%
C:\development\GEPythonProject>set MTENGHOME=%CD%
C:\development\GEPythonProject>python.exe test_proc.py
All commands
C:\>set PATH=C:\Python36;%PATH%
C:\>set DESTDIR=C:\development\GEPythonProject
C:\>set MTENGHOME=C:\mteng19
C:\>chdir %MTENGHOME%
C:\mteng19>gc.exe myproc.gss
C:\mteng19>redist.bat %DESTDIR%
C:\mteng19>xcopy myproc.gss.gcg %DESTDIR%
C:\mteng19>xcopy test_proc.py %DESTDIR%
C:\mteng19>python.exe -m easy_install ge-0.3.1-py3.6-win-amd64.egg
C:\mteng19>chdir %DESTDIR%
C:\development\GEPythonProject>set MTENGHOME=%CD%
C:\development\GEPythonProject>python.exe test_proc.py
Redistribution
After successfully verifying that the test_proc.py file runs, you can now zip up that entire directory and distribute/run it on third-party systems.
Updating GAUSS code
To update the GAUSS code, make the desired changes, recompile myproc.gss and copy it to the staging directory.