utils.py 1.5 KB
Newer Older
1
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
2
# 
3 4 5
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
6
# 
7
#     http://www.apache.org/licenses/LICENSE-2.0
8
# 
9 10 11 12 13
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
14

15
import os
16
import sys
17 18
import six
from distutils.sysconfig import get_python_lib
19
from paddle.utils.cpp_extension.extension_utils import IS_WINDOWS
20

21 22
IS_MAC = sys.platform.startswith('darwin')

23 24 25 26 27 28
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 insalling
# PaddlePaddle whl. So here we specific `include_dirs` to avoid errors in CI.
paddle_includes = [
29 30
    os.path.join(site_packages_path, 'paddle', 'include'),
    os.path.join(site_packages_path, 'paddle', 'include', 'third_party')
31 32
]

33 34 35 36
# Test for extra compile args
extra_cc_args = ['-w', '-g'] if not IS_WINDOWS else ['/w']
extra_nvcc_args = ['-O3']
extra_compile_args = {'cc': extra_cc_args, 'nvcc': extra_nvcc_args}