Description
This model tests Embedded Code Python with Python interpreters of different versions other than GMSPython by setting GMSPYTHONLIB accordingly Contributor: Clemens Westphal, January 2022
Category : GAMS Data Utilities library
Main file : GMSPythonLib.gms includes : GMSPythonLib.gms
$title 'GMSPYTHONLIB compatibility check' (GMSPYTHONLIB,SEQ=142)
$ontext
This model tests Embedded Code Python with Python interpreters
of different versions other than GMSPython by setting
GMSPYTHONLIB accordingly
Contributor: Clemens Westphal, January 2022
$offtext
$set srcRoot %gams.sysdir%apifiles%system.dirsep%Python%system.dirsep%
$ set C ;
$if %system.filesys% == UNIX $set C :
$onEchoV > runTests.gms
$onEmbeddedCode Python:
import sys
py_version = str(sys.version_info.major) + '.' + str(sys.version_info.minor)
if py_version != '%version%':
raise Exception('Expected Python version to be %version% but found ' + py_version)
$offEmbeddedCode
$if not errorfree $abort Exception in Embedded Code Python: Wrong Python version
$call mkdir embpy01
$if not exist embpy01.gms $call.checkErrorLevel testlib -q embpy01
$call.checkErrorLevel gams ../embpy01.gms lo=%GAMS.lo% CDir="%gams.CDir%embpy01"
$call mkdir embpy02
$if not exist embpy02.gms $call.checkErrorLevel testlib -q embpy02
$call.checkErrorLevel gams ../embpy02.gms lo=%GAMS.lo% CDir="%gams.CDir%embpy02"
$if not exist gams2numpy01.gms $call.checkErrorLevel testlib -q gams2numpy01
$call.checkErrorLevel gams gams2numpy01.gms lo=%GAMS.lo% CDir="%gams.CDir%"
$if not exist gams2numpy02.gms $call.checkErrorLevel testlib -q gams2numpy02
$call.checkErrorLevel gams gams2numpy02.gms lo=%GAMS.lo% CDir="%gams.CDir%"
$offEcho
$ifThen setenv PYTHON37
$ call mkdir python37
$ setNames "%sysenv.PYTHON37%" pyDir name ext
$ ifThen.bc %system.buildcode% == WEI
$ setEnv GMSPYTHONLIB "%pyDir%python37.dll"
$ setEnv GMSPYTHONHOME "%pyDir%"
$ prefixPath "%pyDir%"
$ elseIf.bc %system.buildcode% == LEG
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.7m.so"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ elseIf.bc %system.buildcode% == DEG
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.7m.dylib"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ endIf.bc
$ setEnv PYTHONPATH "%srcRoot%api_37%C%%srcRoot%gams"
$ call.checkErrorLevel gams ../runTests.gms CDir=python37 lo=%GAMS.lo% --version 3.7
$endIf
$ifThen setenv PYTHON38
$ call mkdir python38
$ setNames "%sysenv.PYTHON38%" pyDir name ext
$ ifThen.bc %system.buildcode% == WEI
$ setEnv GMSPYTHONLIB "%pyDir%python38.dll"
$ setEnv GMSPYTHONHOME "%pyDir%"
$ prefixPath "%pyDir%"
$ elseIf.bc %system.buildcode% == LEG
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.8.so"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ elseIf.bc %system.buildcode% == DEG
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.8.dylib"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ endIf.bc
$ setEnv PYTHONPATH "%srcRoot%api_38%C%%srcRoot%gams"
$ call.checkErrorLevel gams ../runTests.gms CDir=python38 lo=%GAMS.lo% --version 3.8
$endIf
$ifThen setenv PYTHON39
$ call mkdir python39
$ setNames "%sysenv.PYTHON39%" pyDir name ext
$ ifThen.bc %system.buildcode% == WEI
$ setEnv GMSPYTHONLIB "%pyDir%python39.dll"
$ setEnv GMSPYTHONHOME "%pyDir%"
$ prefixPath "%pyDir%"
$ elseIf.bc %system.buildcode% == LEG
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.9.so"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ elseIf.bc %system.buildcode% == DEG
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.9.dylib"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ endIf.bc
$ setEnv PYTHONPATH "%srcRoot%api_39%C%%srcRoot%gams"
$ call.checkErrorLevel gams ../runTests.gms CDir=python39 lo=%GAMS.lo% --version 3.9
$endIf
$ifThen setenv PYTHON310
$ call mkdir python310
$ setNames "%sysenv.PYTHON310%" pyDir name ext
$ ifThen.bc %system.buildcode% == WEI
$ setEnv GMSPYTHONLIB "%pyDir%python310.dll"
$ setEnv GMSPYTHONHOME "%pyDir%"
$ prefixPath "%pyDir%"
$ elseIf.bc %system.buildcode% == LEG
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.10.so"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ elseIf.bc %system.buildcode% == DEG
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.10.dylib"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ endIf.bc
$ setEnv PYTHONPATH "%srcRoot%api_310%C%%srcRoot%gams"
$ call.checkErrorLevel gams ../runTests.gms CDir=python310 lo=%GAMS.lo% --version 3.10
$endIf