Skip to content

Commit 6e71cc2

Browse files
[Docs] Fix docstrings and add mesh installation script (#1248)
* fix docstrings * add one-key mesh installation shell * Apply suggestions from code review * update install_mesh.sh * fix docs and update install_mesh.sh
1 parent c0b1ced commit 6e71cc2

File tree

10 files changed

+345
-276
lines changed

10 files changed

+345
-276
lines changed

docs/zh/examples/ntopo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ examples/ntopo/ntopo.py:74:86
118118

119119
第二个参数是约束变量的目标值,在本问题按照中希望与方程相关的 $E$ 值 `E_xyz``E_xy` 被优化至 0;
120120

121-
第三个参数是约束方程作用的计算域,此处填入在 [3.5 问题构建](#35) 章节实例化好的相应问题的计算域 `problem.geom["geo"]`
121+
第三个参数是约束方程作用的计算域,此处填入在 [3.5 问题构建](#35-loss) 章节实例化好的相应问题的计算域 `problem.geom["geo"]`
122122

123123
第四个参数是在计算域上的采样配置。
124124

docs/zh/install_setup.md

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -123,54 +123,33 @@ PaddleScience 提供了两种复杂几何类型,如下所示:
123123
[Bracket](./examples/aneurysm.md)、[Aneurysm](./examples/aneurysm.md) 等个别案例使用了 `ppsci.geometry.Mesh` 接口构建复杂几何,因此这些案例运行前需要按照下方给出的命令,安装 open3d、
124124
pybind11、pysdf、PyMesh 四个依赖库(上述**1.1 从 docker 镜像启动**中已安装上述依赖库)。如使用 `ppsci.geometry.SDFMesh` 接口构建复杂几何,则只需要安装 `warp-lang` 即可。
125125

126-
=== "open3d 安装命令"
126+
=== "一键安装[推荐]"
127127

128-
``` sh
129-
python -m pip install open3d -i https://pypi.tuna.tsinghua.edu.cn/simple
130-
```
131-
132-
=== "pybind11 安装命令"
133-
134-
``` sh
135-
python -m pip install pybind11 -i https://pypi.tuna.tsinghua.edu.cn/simple
128+
```sh
129+
bash PaddleScience/install_mesh.sh
136130
```
137131

138-
=== "pysdf 安装命令"
132+
=== "手动安装"
139133

140134
``` sh
141-
python -m pip install pysdf
142-
```
135+
python -m pip install open3d pybind11 pysdf-i https://pypi.tuna.tsinghua.edu.cn/simple
143136
144-
=== "PyMesh 安装命令"
145-
146-
在安装 PyMesh 之前,首先需通过 `cmake --version` 确认环境中是否已安装 cmake。
147-
如果未安装,可以按照下列命令下载并解压 cmake 包,然后将其添加到 PATH 变量中以完成安装。
148-
149-
``` sh
137+
# 在安装 PyMesh 之前,首先需通过 `cmake --version` 确认环境中是否已安装 cmake。
138+
# 如果未安装,可以按照下列命令下载并解压 cmake 包,然后将其添加到 PATH 变量中。
150139
wget -nc https://paddle-org.bj.bcebos.com/paddlescience/cmake-3.23.0-linux-x86_64.tar.gz
151140
tar -zxvf cmake-3.23.0-linux-x86_64.tar.gz
152141
rm -f cmake-3.23.0-linux-x86_64.tar.gz
153-
PATH=$PWD/cmake-3.23.0-linux-x86_64/bin:$PATH
154-
155-
# cmake --version
156-
# cmake version 3.23.0
157-
158-
# CMake suite maintained and supported by Kitware (kitware.com/cmake).
159-
```
160-
161-
推荐以 setup 的方式安装 PyMesh 库,命令如下:
142+
export PATH=$PWD/cmake-3.23.0-linux-x86_64/bin:$PATH
162143
163-
``` sh
144+
# 推荐以 setup 的方式安装 PyMesh 库,命令如下:
164145
wget -nc https://paddle-org.bj.bcebos.com/paddlescience/PyMesh.tar.gz
165146
tar -zxvf PyMesh.tar.gz
166147
167148
# 也可以使用 git 命令下载,速度可能会比较慢
168149
# git clone https://github.com/PyMesh/PyMesh.git
169150
# git submodule update --init --recursive --progress
170151
171-
cd PyMesh
172-
export PYMESH_PATH=`pwd`
173-
152+
# 安装必要依赖包
174153
apt-get install \
175154
libeigen3-dev \
176155
libgmp-dev \
@@ -181,16 +160,11 @@ PaddleScience 提供了两种复杂几何类型,如下所示:
181160
libtbb-dev \
182161
python3-dev
183162
184-
python -m pip install --user -r $PYMESH_PATH/python/requirements.txt
163+
cd PyMesh
164+
export PYMESH_PATH=`pwd`
165+
python -m pip install -r $PYMESH_PATH/python/requirements.txt
185166
python setup.py build
186-
python setup.py install --user
187-
188-
# test whether installed successfully
189-
python -c "import pymesh; pymesh.test()"
190-
191-
# Ran 175 tests in 3.150s
192-
193-
# OK (SKIP=2)
167+
python setup.py install
194168
```
195169

196170
!!! warning "安装注意事项"

install_mesh.sh

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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

Comments
 (0)