|
| 1 | +#!/bin/bash |
| 2 | +set -ex |
| 3 | + |
| 4 | +echo "==== Step 1: Checking Python Environment ====" |
| 5 | +which python |
| 6 | +python -V |
| 7 | +echo "==== Python Environment Verified ====" |
| 8 | + |
| 9 | + |
| 10 | +echo "==== Step 2: Checking CMake Environment ====" |
| 11 | +# Verify if cmake exists in current environment. If not, download a temporary version. |
| 12 | +if command -v cmake >/dev/null 2>&1; then |
| 13 | + echo "CMake found: $(cmake --version | head -n 1)" |
| 14 | +else |
| 15 | + echo "CMake not found. Installing temporary CMake 3.23.0 ..." |
| 16 | + wget -nc https://paddle-org.bj.bcebos.com/paddlescience/cmake-3.23.0-linux-x86_64.tar.gz |
| 17 | + tar -zxf cmake-3.23.0-linux-x86_64.tar.gz --checkpoint=.100 --totals |
| 18 | + rm -f cmake-3.23.0-linux-x86_64.tar.gz |
| 19 | + export PATH=$PWD/cmake-3.23.0-linux-x86_64/bin:$PATH |
| 20 | + echo "Temporary CMake installed: $(cmake --version | head -n 1)" |
| 21 | +fi |
| 22 | +echo "CMake environment ready." |
| 23 | + |
| 24 | + |
| 25 | +echo "==== Step 3: Downloading PyMesh Package ====" |
| 26 | +# Download PyMesh package if not already present. |
| 27 | +wget -nc https://paddle-org.bj.bcebos.com/paddlescience/PyMesh.tar.gz |
| 28 | +echo "Download completed. Extracting package..." |
| 29 | +tar -zxf PyMesh.tar.gz --checkpoint=.1000 --totals |
| 30 | +echo "PyMesh package extracted." |
| 31 | + |
| 32 | + |
| 33 | +echo "==== Step 4: Entering PyMesh Directory ====" |
| 34 | +cd PyMesh |
| 35 | +export PYMESH_PATH=$(pwd) |
| 36 | +echo "PYMESH_PATH is set to: $PYMESH_PATH" |
| 37 | + |
| 38 | + |
| 39 | +echo "==== Step 5: Installing GCC-9 Toolchain ====" |
| 40 | +# Install gcc-9 and configure build toolchain. |
| 41 | +apt-get install gcc-9 -y |
| 42 | +export CC=/usr/bin/gcc-9 |
| 43 | +export CXX=/usr/bin/g++-9 |
| 44 | +export LDFLAGS="-Wl,--allow-multiple-definition" |
| 45 | +echo "GCC-9 and linker flags configured." |
| 46 | + |
| 47 | + |
| 48 | +echo "==== Step 6: Installing Required System Libraries ====" |
| 49 | +# Install core dependencies required by PyMesh. |
| 50 | +apt-get install \ |
| 51 | + libeigen3-dev \ |
| 52 | + libgmp-dev \ |
| 53 | + libgmpxx4ldbl \ |
| 54 | + libmpfr-dev \ |
| 55 | + libboost-dev \ |
| 56 | + libboost-thread-dev \ |
| 57 | + libtbb-dev -y |
| 58 | +echo "System dependencies installed." |
| 59 | + |
| 60 | + |
| 61 | +echo "==== Step 7: Installing Python Dependencies ====" |
| 62 | +# Install Python dependencies including PyBind11, pysdf, and Open3D. |
| 63 | +python -m pip install -r $PYMESH_PATH/python/requirements.txt |
| 64 | +python -m pip install pybind11 -i https://pypi.tuna.tsinghua.edu.cn/simple |
| 65 | +python -m pip install pysdf -i https://pypi.tuna.tsinghua.edu.cn/simple |
| 66 | +python -m pip install open3d -i https://pypi.tuna.tsinghua.edu.cn/simple |
| 67 | +echo "Python dependencies installed." |
| 68 | + |
| 69 | + |
| 70 | +echo "==== Step 8: Building PyMesh ====" |
| 71 | +# Build PyMesh using setup.py |
| 72 | +python setup.py build |
| 73 | +echo "PyMesh build completed." |
| 74 | + |
| 75 | + |
| 76 | +echo "==== Step 9: Installing PyMesh ====" |
| 77 | +# Install PyMesh into current Python environment. |
| 78 | +python setup.py install |
| 79 | +echo "PyMesh installation completed." |
| 80 | + |
| 81 | + |
| 82 | +echo "==== Step 10: Cleaning Temporary Files ====" |
| 83 | +cd .. |
| 84 | + |
| 85 | +# Remove downloaded archive and build artifacts. |
| 86 | +rm -f PyMesh.tar.gz |
| 87 | +rm -rf PyMesh/build |
| 88 | + |
| 89 | +# Remove temporary CMake directory if it was installed. |
| 90 | +if [ -d "./cmake-3.23.0-linux-x86_64" ]; then |
| 91 | + echo "Removing temporary CMake directory..." |
| 92 | + rm -rf ./cmake-3.23.0-linux-x86_64 |
| 93 | +fi |
| 94 | + |
| 95 | +echo "Cleanup completed." |
| 96 | + |
| 97 | + |
| 98 | +# Optional test section |
| 99 | +# echo "==== Step 11: Running PyMesh Tests ====" |
| 100 | +# python -c "import pymesh; pymesh.test()" |
| 101 | +# echo "PyMesh tests finished." |
0 commit comments