Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setuptools optimization #48770

Merged
merged 5 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions paddle/scripts/paddle_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3468,20 +3468,7 @@ function run_setup(){
SYSTEM=`uname -s`
if [ "$SYSTEM" == "Darwin" ]; then
echo "Using python abi: $1"
risemeup1 marked this conversation as resolved.
Show resolved Hide resolved
if [ "$1" == "cp36-cp36m" ] || [ "$1" == "" ]; then
if [ -d "/Library/Frameworks/Python.framework/Versions/3.6" ]; then
export LD_LIBRARY_PATH=/Library/Frameworks/Python.framework/Versions/3.6/lib/
export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/Library/Frameworks/Python.framework/Versions/3.6/lib/
export PATH=/Library/Frameworks/Python.framework/Versions/3.6/bin/:${PATH}
#after changing "PYTHON_LIBRARY:FILEPATH" to "PYTHON_LIBRARY" ,we can use export
export PYTHON_EXECUTABLE=/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
export PYTHON_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m/
export PYTHON_LIBRARY=/Library/Frameworks/Python.framework/Versions/3.6/lib/libpython3.6m.dylib
pip3.6 install --user -r ${PADDLE_ROOT}/python/requirements.txt
else
exit 1
fi
elif [ "$1" == "cp37-cp37m" ]; then
if [ "$1" == "cp37-cp37m" ]; then
if [ -d "/Library/Frameworks/Python.framework/Versions/3.7" ]; then
export LD_LIBRARY_PATH=/Library/Frameworks/Python.framework/Versions/3.7/lib/
export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/Library/Frameworks/Python.framework/Versions/3.7/lib/
Expand Down
25 changes: 17 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from distutils.spawn import find_executable
from subprocess import CalledProcessError

from setuptools import Command, Distribution, Extension, setup
from setuptools import Command, Extension, setup
from setuptools.command.egg_info import egg_info
from setuptools.command.install import install as InstallCommandBase
from setuptools.command.install_lib import install_lib
Expand Down Expand Up @@ -275,7 +275,7 @@ def _mkdir_p(dir_str):
try:
os.makedirs(dir_str)
except OSError as e:
raise RuntimeError("Failed to create folder build/")
raise RuntimeError("Failed to create build folder")


def get_major():
Expand Down Expand Up @@ -583,9 +583,14 @@ def build_run(args, build_path, envrion_var):

def build_steps():
print('------- Building start ------')
if not os.path.exists(TOP_DIR + '/build'):
_mkdir_p(TOP_DIR + '/build')
build_path = TOP_DIR + '/build'
build_dir = os.getenv("BUILD_DIR")
if build_dir is not None:
build_dir = TOP_DIR + '/' + build_dir
else:
build_dir = TOP_DIR + '/build'
if not os.path.exists(build_dir):
_mkdir_p(build_dir)
build_path = build_dir
# run cmake to generate native build files
cmake_cache_file_path = os.path.join(build_path, "CMakeCache.txt")
# if rerun_cmake is True,remove CMakeCache.txt and rerun camke
Expand Down Expand Up @@ -1276,9 +1281,13 @@ def main():
# Execute the build process,cmake and make
if cmake_and_build:
build_steps()

sys.path.append(TOP_DIR + "/build/python/")
from build.python.env_dict import env_dict as env_dict
build_dir = os.getenv("BUILD_DIR")
if build_dir is not None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里可以直接写build_dir = "build",下面就可以共用相同逻辑

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的

env_dict_path = TOP_DIR + '/' + build_dir + '/python'
else:
env_dict_path = TOP_DIR + "/build/python/"
sys.path.append(env_dict_path)
from env_dict import env_dict as env_dict

global env_dict
global paddle_binary_dir, paddle_source_dir
Expand Down