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
$if not set DEMOSIZE $set DEMOSIZE 0
$set srcRoot %gams.sysdir%apifiles%system.dirsep%Python%system.dirsep%
$onEchoV > runEmbpy.gms
$call mkdir embpy%1
$if not exist embpy%1.gms $call.checkErrorLevel testlib -q embpy%1
$call.checkErrorLevel '"%gams.sysdir%gams" ../embpy%1.gms lo=%GAMS.lo% CDir="%gams.CDir%embpy%1"'
$offEcho
$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
$batInclude ../runEmbpy 01
$batInclude ../runEmbpy 02
$batInclude ../runEmbpy 03
$batInclude ../runEmbpy 04
$batInclude ../runEmbpy 05
$batInclude ../runEmbpy 06
$batInclude ../runEmbpy 07
$batInclude ../runEmbpy 08
$batInclude ../runEmbpy 09
$batInclude ../runEmbpy 10
$batInclude ../runEmbpy 11
$batInclude ../runEmbpy 12
$batInclude ../runEmbpy 13
$if not exist gams2numpy01.gms $call.checkErrorLevel testlib -q gams2numpy01
$call.checkErrorLevel '"%gams.sysdir%gams" gams2numpy01.gms lo=%GAMS.lo% CDir="%gams.CDir%"'
$if not exist gams2numpy02.gms $call.checkErrorLevel testlib -q gams2numpy02
$call.checkErrorLevel '"%gams.sysdir%gams" gams2numpy02.gms lo=%GAMS.lo% CDir="%gams.CDir%"'
$if not exist gdxencoding1.gms $call.checkErrorLevel testlib -q gdxencoding1
$call.checkErrorLevel '"%gams.sysdir%gams" gdxencoding1.gms lo=%GAMS.lo% CDir="%gams.CDir%"'
$if not exist idc01.gms $call.checkErrorLevel testlib -q idc01
$call.checkErrorLevel '"%gams.sysdir%gams" idc01.gms lo=%GAMS.lo% CDir="%gams.CDir%"'
$if not exist implset1.gms $call.checkErrorLevel testlib -q implset1
$call.checkErrorLevel '"%gams.sysdir%gams" implset1.gms lo=%GAMS.lo% CDir="%gams.CDir%"'
$if not exist loop10.gms $call.checkErrorLevel testlib -q loop10
$call.checkErrorLevel '"%gams.sysdir%gams" loop10.gms lo=%GAMS.lo% CDir="%gams.CDir%"'
$if not exist zerotoeps1.gms $call.checkErrorLevel testlib -q zerotoeps1
$call.checkErrorLevel '"%gams.sysdir%gams" zerotoeps1.gms lo=%GAMS.lo% CDir="%gams.CDir%"'
$if not exist gtmvn.gms $call.checkErrorLevel datalib -q gtmvn
$call.checkErrorLevel '"%gams.sysdir%gams" gtmvn.gms lo=%GAMS.lo% CDir="%gams.CDir%"'
$if not exist embeddedSort.gms $call.checkErrorLevel datalib -q embeddedSort
$call.checkErrorLevel '"%gams.sysdir%gams" embeddedSort.gms lo=%GAMS.lo% CDir="%gams.CDir%"'
$if not exist embeddedSplit.gms $call.checkErrorLevel datalib -q embeddedSplit
$call.checkErrorLevel '"%gams.sysdir%gams" embeddedSplit.gms lo=%GAMS.lo% CDir="%gams.CDir%"'
* Connect tests
$if not exist caconcat.gms $call.checkErrorLevel testlib -q caconcat
$call.checkErrorLevel '"%gams.sysdir%gams" caconcat.gms lo=%GAMS.lo% CDir="%gams.CDir%"'
$if not exist cacsvr.gms $call.checkErrorLevel testlib -q cacsvr
$call.checkErrorLevel '"%gams.sysdir%gams" cacsvr.gms lo=%GAMS.lo% CDir="%gams.CDir%"'
$if not exist cagamsrw.gms $call.checkErrorLevel testlib -q cagamsrw
$call.checkErrorLevel '"%gams.sysdir%gams" cagamsrw.gms lo=%GAMS.lo% CDir="%gams.CDir%"'
$if not exist cagdxrw.gms $call.checkErrorLevel testlib -q cagdxrw
$call.checkErrorLevel '"%gams.sysdir%gams" cagdxrw.gms lo=%GAMS.lo% CDir="%gams.CDir%"'
$if %DEMOSIZE% == 1 $exit
* More Connect tests
$if not exist cacsvw.gms $call.checkErrorLevel testlib -q cacsvw
$call.checkErrorLevel '"%gams.sysdir%gams" cacsvw.gms lo=%GAMS.lo% CDir="%gams.CDir%"'
$if not exist cafilter.gms $call.checkErrorLevel testlib -q cafilter
$call.checkErrorLevel '"%gams.sysdir%gams" cafilter.gms lo=%GAMS.lo% CDir="%gams.CDir%"'
$if not exist cadomainw.gms $call.checkErrorLevel testlib -q cadomainw
$call.checkErrorLevel '"%gams.sysdir%gams" cadomainw.gms lo=%GAMS.lo% CDir="%gams.CDir%"'
$if not exist calabelm.gms $call.checkErrorLevel testlib -q calabelm
$call.checkErrorLevel '"%gams.sysdir%gams" calabelm.gms lo=%GAMS.lo% CDir="%gams.CDir%"'
$if not exist caproject.gms $call.checkErrorLevel testlib -q caproject
$call.checkErrorLevel '"%gams.sysdir%gams" caproject.gms lo=%GAMS.lo% CDir="%gams.CDir%"'
$offEcho
$ifThen setenv PYTHON39
$ call mkdir python39
$ setNames "%sysenv.PYTHON39%" pyDir name ext
$ ifThen.bc %system.platform% == WEX
$ setEnv GMSPYTHONLIB "%pyDir%python39.dll"
$ setEnv GMSPYTHONHOME "%pyDir%"
$ prefixPath "%pyDir%"
$ elseIf.bc %system.platform% == LEX
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.9.so"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ elseIf.bc %system.platform% == DEX
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.9.dylib"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ elseIf.bc %system.platform% == DAX
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.9.dylib"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ endIf.bc
$ call.checkErrorLevel gams ../runTests.gms CDir=python39 lo=%GAMS.lo% --version 3.9 --DEMOSIZE=%DEMOSIZE%
$endIf
$ifThen setenv PYTHON310
$ call mkdir python310
$ setNames "%sysenv.PYTHON310%" pyDir name ext
$ ifThen.bc %system.platform% == WEX
$ setEnv GMSPYTHONLIB "%pyDir%python310.dll"
$ setEnv GMSPYTHONHOME "%pyDir%"
$ prefixPath "%pyDir%"
$ elseIf.bc %system.platform% == LEX
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.10.so"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ elseIf.bc %system.platform% == DEX
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.10.dylib"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ elseIf.bc %system.platform% == DAX
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.10.dylib"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ endIf.bc
$ call.checkErrorLevel gams ../runTests.gms CDir=python310 lo=%GAMS.lo% --version 3.10 --DEMOSIZE=%DEMOSIZE%
$endIf
$ifThen setenv PYTHON311
$ call mkdir python311
$ setNames "%sysenv.PYTHON311%" pyDir name ext
$ ifThen.bc %system.platform% == WEX
$ setEnv GMSPYTHONLIB "%pyDir%python311.dll"
$ setEnv GMSPYTHONHOME "%pyDir%"
$ prefixPath "%pyDir%"
$ elseIf.bc %system.platform% == LEX
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.11.so"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ elseIf.bc %system.platform% == DEX
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.11.dylib"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ elseIf.bc %system.platform% == DAX
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.11.dylib"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ endIf.bc
$ call.checkErrorLevel gams ../runTests.gms CDir=python311 lo=%GAMS.lo% --version 3.11 --DEMOSIZE=%DEMOSIZE%
$endIf
$ifThen setenv PYTHON312
$ call mkdir python312
$ setNames "%sysenv.PYTHON312%" pyDir name ext
$ ifThen.bc %system.platform% == WEX
$ setEnv GMSPYTHONLIB "%pyDir%python312.dll"
$ setEnv GMSPYTHONHOME "%pyDir%"
$ prefixPath "%pyDir%"
$ elseIf.bc %system.platform% == LEX
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.12.so"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ elseIf.bc %system.platform% == DEX
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.12.dylib"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ elseIf.bc %system.platform% == DAX
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.12.dylib"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ endIf.bc
$ call.checkErrorLevel gams ../runTests.gms CDir=python312 lo=%GAMS.lo% --version 3.12 --DEMOSIZE=%DEMOSIZE%
$endIf
$ifThen setenv PYTHON313
$ call mkdir python313
$ setNames "%sysenv.PYTHON313%" pyDir name ext
$ ifThen.bc %system.platform% == WEX
$ setEnv GMSPYTHONLIB "%pyDir%python313.dll"
$ setEnv GMSPYTHONHOME "%pyDir%"
$ prefixPath "%pyDir%"
$ elseIf.bc %system.platform% == LEX
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.13.so"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ elseIf.bc %system.platform% == DEX
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.13.dylib"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ elseIf.bc %system.platform% == DAX
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.13.dylib"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ endIf.bc
$ call.checkErrorLevel gams ../runTests.gms CDir=python313 lo=%GAMS.lo% --version 3.13 --DEMOSIZE=%DEMOSIZE%
$endIf