From: Nabil Ghodbane Date: Fri, 2 Aug 2024 08:14:32 +0000 (+0200) Subject: spns #42665: MeshIO: GMSH and ANSYS (II) X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5721956e1a6892f6f567a0ee3c0168b7a4fb962a;p=tools%2Fsat_salome.git spns #42665: MeshIO: GMSH and ANSYS (II) --- diff --git a/products/compil_scripts/meshio-4.3.13.sh b/products/compil_scripts/meshio-4.3.13.sh index 94551a5..45d7cc0 100755 --- a/products/compil_scripts/meshio-4.3.13.sh +++ b/products/compil_scripts/meshio-4.3.13.sh @@ -15,7 +15,9 @@ cd $BUILD_DIR export PYTHONPATH=${PRODUCT_INSTALL}/lib/python${PYTHON_VERSION}/site-packages:$PYTHONPATH export PATH=${PRODUCT_INSTALL}/bin:$PATH -WHEELS=('cached_property-1.5.2-py2.py3-none-any.whl' 'meshio-4.3.13-py3-none-any.whl') +WHEELS=('cached_property-1.5.2-py2.py3-none-any.whl' + 'meshio-4.3.13-py3-none-any.whl' + ) for WHEEL in "${WHEELS[@]}"; do ${PYTHONBIN} -m pip install --cache-dir=$BUILD_DIR/cache/pip $SOURCE_DIR/$WHEEL --prefix=$PRODUCT_INSTALL if [ $? -ne 0 ]; then @@ -24,5 +26,40 @@ for WHEEL in "${WHEELS[@]}"; do fi done +# bos #42618 - https://github.com/nschloe/meshio/issues/1484 +fPy=$PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/gmsh/main.py +if [ -f $fPy ]; then + sed -i 's/"gmsh": lambda f, m, \*\*kwargs: write(f, m, "4.1", \*\*kwargs)/"gmsh": lambda f, m, \*\*kwargs: write(f, m, "4.0", \*\*kwargs)/g' $fPy + if [ $? -ne 0 ]; then + echo "FATAL: could not apply fixes to GMSH MeshIO driver" + exit 1 + fi +else + echo "FATAL: could not find GMSH MeshIO driver!" + exit 1 +fi + +# spns #42665 +fPy=$PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/ansys/_ansys.py +if [ -f $fPy ]; then + statusCode=0 + # retrieve line number + l=$(grep -nA0 "raise KeyError" $fPy|cut -d':' -f1) + L=$(($l+2)) + sed -i 's/raise KeyError(/warn(/g' $fPy + statusCode=$(($statusCode+$?)) + sed -i "${L}s/)/)\n continue/g" $fPy + statusCode=$(($statusCode+$?)) + sed -i 's/(legal: {legal_keys})/(legal: {legal_keys}). Cell will be skipped!/g' $fPy + statusCode=$(($statusCode+$?)) + if [ $statusCode -ne 0 ]; then + echo "FATAL: could not apply fixes to ANSYS MeshIO driver" + exit 1 + fi +else + echo "FATAL: could not find ANSYS MeshIO driver!" + exit 1 +fi + echo echo "########## END" diff --git a/products/compil_scripts/meshio-5.3.4.sh b/products/compil_scripts/meshio-5.3.4.sh index ed3c5bc..667e5ed 100755 --- a/products/compil_scripts/meshio-5.3.4.sh +++ b/products/compil_scripts/meshio-5.3.4.sh @@ -36,8 +36,8 @@ esac pyVersionMajor=python$($PYTHONBIN -c 'import sys; print(".".join(map(str, sys.version_info[0:1])))') if [ $? -ne 0 ]; then - echo ERROR: Failed to extract major Python version - assuming Python version equal to 3... - pyVersionMajor=python3 + echo ERROR: Failed to extract major Python version - assuming Python version equal to 3... + pyVersionMajor=python3 fi echo INFO: Python version major: ${pyVersionMajor} @@ -49,23 +49,37 @@ else fi # bos #42618 - https://github.com/nschloe/meshio/issues/1484 -if [ -f $PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/gmsh/main.py ]; then - sed -i '/"gmsh22"/a \ \ \ \ \ \ \ \ "gmsh40": lambda f, m, **kwargs: write(f, m, "4.0", **kwargs),' $PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/gmsh/main.py +fPy=$PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/gmsh/main.py +if [ -f $fPy ]; then + sed -i 's/"gmsh": lambda f, m, \*\*kwargs: write(f, m, "4.1", \*\*kwargs)/"gmsh": lambda f, m, \*\*kwargs: write(f, m, "4.0", \*\*kwargs)/g' $fPy + if [ $? -ne 0 ]; then + echo "FATAL: could not apply fixes to GMSH MeshIO driver" + exit 1 + fi else - echo "FATAL: could not find gmsh meshio driver!" + echo "FATAL: could not find GMSH MeshIO driver!" exit 1 fi # spns #42665 -if [ -f $PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/ansys/_ansys.py ]; then +fPy=$PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/ansys/_ansys.py +if [ -f $fPy ]; then + statusCode=0 # retrieve line number - l=$(grep -nA0 "raise KeyError" $PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/ansys/_ansys.py|cut -d':' -f1) + l=$(grep -nA0 "raise KeyError" $fPy|cut -d':' -f1) L=$(($l+2)) - sed -i 's/raise KeyError(/warn(/g' $PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/ansys/_ansys.py - # move to next cell - sed -i "${L}s/)/)\n continue/g" $PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/ansys/_ansys.py + sed -i 's/raise KeyError(/warn(/g' $fPy + statusCode=$(($statusCode+$?)) + sed -i "${L}s/)/)\n continue/g" $fPy + statusCode=$(($statusCode+$?)) + sed -i 's/(legal: {legal_keys})/(legal: {legal_keys}). Cell will be skipped!/g' $fPy + statusCode=$(($statusCode+$?)) + if [ $statusCode -ne 0 ]; then + echo "FATAL: could not apply fixes to ANSYS MeshIO driver" + exit 1 + fi else - echo "FATAL: could not find ansys meshio driver!" + echo "FATAL: could not find ANSYS MeshIO driver!" exit 1 fi diff --git a/products/compil_scripts/meshio-5.3.5.sh b/products/compil_scripts/meshio-5.3.5.sh index 8f39cef..02ed832 100755 --- a/products/compil_scripts/meshio-5.3.5.sh +++ b/products/compil_scripts/meshio-5.3.5.sh @@ -41,23 +41,37 @@ else fi # bos #42618 - https://github.com/nschloe/meshio/issues/1484 -if [ -f $PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/gmsh/main.py ]; then - sed -i '/"gmsh22"/a \ \ \ \ \ \ \ \ "gmsh40": lambda f, m, **kwargs: write(f, m, "4.0", **kwargs),' $PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/gmsh/main.py +fPy=$PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/gmsh/main.py +if [ -f $fPy ]; then + sed -i 's/"gmsh": lambda f, m, \*\*kwargs: write(f, m, "4.1", \*\*kwargs)/"gmsh": lambda f, m, \*\*kwargs: write(f, m, "4.0", \*\*kwargs)/g' $fPy + if [ $? -ne 0 ]; then + echo "FATAL: could not apply fixes to GMSH MeshIO driver" + exit 1 + fi else - echo "FATAL: could not find gmsh meshio driver!" + echo "FATAL: could not find GMSH MeshIO driver!" exit 1 fi # spns #42665 -if [ -f $PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/ansys/_ansys.py ]; then +fPy=$PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/ansys/_ansys.py +if [ -f $fPy ]; then + statusCode=0 # retrieve line number - l=$(grep -nA0 "raise KeyError" $PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/ansys/_ansys.py|cut -d':' -f1) + l=$(grep -nA0 "raise KeyError" $fPy|cut -d':' -f1) L=$(($l+2)) - sed -i 's/raise KeyError(/warn(/g' $PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/ansys/_ansys.py - # move to next cell - sed -i "${L}s/)/)\n continue/g" $PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/ansys/_ansys.py + sed -i 's/raise KeyError(/warn(/g' $fPy + statusCode=$(($statusCode+$?)) + sed -i "${L}s/)/)\n continue/g" $fPy + statusCode=$(($statusCode+$?)) + sed -i 's/(legal: {legal_keys})/(legal: {legal_keys}). Cell will be skipped!/g' $fPy + statusCode=$(($statusCode+$?)) + if [ $statusCode -ne 0 ]; then + echo "FATAL: could not apply fixes to ANSYS MeshIO driver" + exit 1 + fi else - echo "FATAL: could not find ansys meshio driver!" + echo "FATAL: could not find ANSYS MeshIO driver!" exit 1 fi