Description
This model performs simple checks on the GMSPython distribution shipped with GAMS regarding the package versions of distributed files as well as the total disk size. In addition, the conda environment used for assembling GMSPython is checked for known vulnerabilities using pip-audit. Contributor: Clemens Westphal, April 2020
Category : GAMS Data Utilities library
Main file : GMSPythonCheck.gms includes : GMSPythonCheck.gms
$title 'Consistency and vulnerability check for GMSPython' (GMSPYTHONCHECK,SEQ=140)
$onText
This model performs simple checks on the GMSPython
distribution shipped with GAMS regarding the package versions
of distributed files as well as the total disk size.
In addition, the conda environment used for assembling GMSPython
is checked for known vulnerabilities using pip-audit.
Contributor: Clemens Westphal, April 2020
$offText
$dropEnv PYTHONUSERBASE
* check disk size
* check redistributed packages
* Report errors regarding disk size or packages
* Run pip-audit to check conda environment (gmspython) used for assembling GMSPython for vulnerabilities
* skip if no miniconda
$if not setenv MINICONDA $exit
* skip if not building master or distXX and FORCEPIPAUDIT not set
$if not setenv FORCEPIPAUDIT $if not %sysenv.GBRANCHNAME% == master $if not %sysenv.GBRANCHNAME% == dist%sysenv.GVERSIONMAJOR% $exit
* Default behavior for Python warnings to avoid conda warnings
$dropEnv PYTHONWARNINGS
$onEcho > run_pip_audit.sh
fail=0
unset PYTHONUSERBASE
eval "$($MINICONDA shell.bash hook)"
env=gmspython
[ -d ${GPORTBIN}/condaenvs/$env ] || exit 0
conda activate ${GPORTBIN}/condaenvs/$env
PYTHONUSERBASE=${GPORTBIN}/condaenvs/pythonuserbase/$env pip install pip-audit==2.7.3 --no-warn-script-location --user > /dev/null 2>&1 || { echo "Problems installing pip-audit in conda environment ${env}" ; exit 1; }
python -m pip_audit --cache-dir ./pip_audit_cache/$env --verbose > pip_audit.log 2>&1
let "fail = $?"
conda deactivate
conda deactivate
cp pip_audit.log "${GTESTDIR}/${MODTESTDIR}/pip_audit.log"
if grep -i 'Dependency not found' pip_audit.log | grep -v -i 'gamsapi'; then
let "fail = 1"
fi
exit $fail
$offEcho
$call chmod +x ./run_pip_audit.sh
$call bash ./run_pip_audit.sh
$ifE errorlevel<>0 $abort "Failures running pip-audit. Inspect pip_audit.log for details."