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%
$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%"'
$offEcho
$ifThen setenv PYTHON38
$ call mkdir python38
$ setNames "%sysenv.PYTHON38%" pyDir name ext
$ ifThen.bc %system.platform% == WEX
$ setEnv GMSPYTHONLIB "%pyDir%python38.dll"
$ setEnv GMSPYTHONHOME "%pyDir%"
$ prefixPath "%pyDir%"
$ elseIf.bc %system.platform% == LEX
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.8.so"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ elseIf.bc %system.platform% == DEX
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.8.dylib"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ elseIf.bc %system.platform% == DAX
$ setEnv GMSPYTHONLIB "%pyDir%..%system.dirsep%lib%system.dirsep%libpython3.8.dylib"
$ setEnv GMSPYTHONHOME "%pyDir%..%system.dirsep%"
$ endIf.bc
$ 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.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
$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
$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
$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
$endIf