Describe the bug
在 Ubuntu/Debian 系统上,从源码编译 paddle2onnx 时 cmake 配置失败,报错 "No valid site-packages path found"。
Root cause
CMakeLists.txt:103 使用 site.getsitepackages() 获取 Python 包路径,但:
-
Ubuntu/Debian 使用 dist-packages 而非 site-packages
python3 -c "import site; print(site.getsitepackages())" 返回的是 /usr/lib/python3/dist-packages 等路径,
但 cmake 的正则检查是 SITE_PACKAGES MATCHES "site-packages",永远匹配不上 dist-packages。
-
未检查 site.getusersitepackages()
当用户通过 pip install --user 安装 paddle(比如在用户空间而非系统空间),
paddle 装在 ~/.local/lib/python3.10/site-packages,
但这个路径不在 site.getsitepackages() 的返回值中,
因此 cmake 无法发现 paddle 的 C++ 库。
Reproduction
在 Ubuntu 22.04 上,PaddlePaddle 通过 pip install --user paddlepaddle-gpu 安装:
git clone https://github.com/PaddlePaddle/Paddle2ONNX.git
cd Paddle2ONNX
pip install --no-build-isolation -v .
CMake Error at CMakeLists.txt:116 (message):
No valid site-packages path found.
Fix (PR prepared)
CMakeLists.txt:103 将调用改为同时查询系统路径和用户路径:
# Before
"import site; print(';'.join(site.getsitepackages()))"
# After
"import site; sp = site.getsitepackages() + [site.getusersitepackages()]; print(';'.join(sp))"
这样 cmake 会同时检查 dist-packages(Ubuntu 系统路径)和 ~/.local/.../site-packages(用户安装路径)。
Informations (please complete the following information):
- OS: Ubuntu 22.04
- Paddle2ONNX Version: source commit 1877292
- PaddlePaddle Version: 3.5.0.dev20260614
- Python: 3.10
Additional context
这是一个纯构建系统修复,不影响运行时行为。修复后已验证 cmake 配置在 Ubuntu 22.04 + pip install --user 环境下通过。
Describe the bug
在 Ubuntu/Debian 系统上,从源码编译 paddle2onnx 时 cmake 配置失败,报错 "No valid site-packages path found"。
Root cause
CMakeLists.txt:103使用site.getsitepackages()获取 Python 包路径,但:Ubuntu/Debian 使用
dist-packages而非site-packagespython3 -c "import site; print(site.getsitepackages())"返回的是/usr/lib/python3/dist-packages等路径,但 cmake 的正则检查是
SITE_PACKAGES MATCHES "site-packages",永远匹配不上dist-packages。未检查
site.getusersitepackages()当用户通过
pip install --user安装 paddle(比如在用户空间而非系统空间),paddle 装在
~/.local/lib/python3.10/site-packages,但这个路径不在
site.getsitepackages()的返回值中,因此 cmake 无法发现 paddle 的 C++ 库。
Reproduction
在 Ubuntu 22.04 上,PaddlePaddle 通过
pip install --user paddlepaddle-gpu安装:Fix (PR prepared)
CMakeLists.txt:103将调用改为同时查询系统路径和用户路径:这样 cmake 会同时检查
dist-packages(Ubuntu 系统路径)和~/.local/.../site-packages(用户安装路径)。Informations (please complete the following information):
Additional context
这是一个纯构建系统修复,不影响运行时行为。修复后已验证 cmake 配置在 Ubuntu 22.04 + pip install --user 环境下通过。