From 9f47aac954db2191247a451308be27a998fed4a9 Mon Sep 17 00:00:00 2001 From: HongyuJia Date: Thu, 22 Dec 2022 20:58:35 +0800 Subject: [PATCH] fix custom operator testcase CI error (#49270) --- python/paddle/fluid/tests/custom_op/utils.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/python/paddle/fluid/tests/custom_op/utils.py b/python/paddle/fluid/tests/custom_op/utils.py index 671d412e80..69530da604 100644 --- a/python/paddle/fluid/tests/custom_op/utils.py +++ b/python/paddle/fluid/tests/custom_op/utils.py @@ -14,21 +14,24 @@ import os import sys -from distutils.sysconfig import get_python_lib +from site import getsitepackages from paddle.utils.cpp_extension.extension_utils import IS_WINDOWS IS_MAC = sys.platform.startswith('darwin') -site_packages_path = get_python_lib() # Note(Aurelius84): We use `add_test` in Cmake to config how to run unittest in CI. # `PYTHONPATH` will be set as `build/python/paddle` that will make no way to find # paddle include directory. Because the following path is generated after installing # PaddlePaddle whl. So here we specific `include_dirs` to avoid errors in CI. -paddle_includes = [ - os.path.join(site_packages_path, 'paddle', 'include'), - os.path.join(site_packages_path, 'paddle', 'include', 'third_party'), -] +paddle_includes = [] +for site_packages_path in getsitepackages(): + paddle_includes.append( + os.path.join(site_packages_path, 'paddle', 'include') + ) + paddle_includes.append( + os.path.join(site_packages_path, 'paddle', 'include', 'third_party') + ) # Test for extra compile args extra_cc_args = ['-w', '-g'] if not IS_WINDOWS else ['/w'] -- GitLab