未验证 提交 e4e3675f 编写于 作者: R risemeup1 提交者: GitHub

optimizing setup.py develop command (#51528)

* optimizing setup.py develop command

* add libpaddle.so

* modify setup.py

* add python/paddle/distributed/fleet/.gitignore

* add libpaddle.so to .gitignore

* add *.so to python/paddle/libs/.gitignore

* add new gitignore
上级 6bd5b7ce
......@@ -7,3 +7,4 @@ paddlepaddle_gpu.egg-info
.idea
paddle/proto/*.py
paddle/proto/*.pyc
_foo.*
......@@ -27,6 +27,7 @@ from distutils.spawn import find_executable
from subprocess import CalledProcessError
from setuptools import Command, Extension, setup
from setuptools.command.develop import develop as DevelopCommandBase
from setuptools.command.egg_info import egg_info
from setuptools.command.install import install as InstallCommandBase
from setuptools.command.install_lib import install_lib
......@@ -222,6 +223,55 @@ class InstallCommand(InstallCommandBase):
return ret
class DevelopCommand(DevelopCommandBase):
def run(self):
# copy proto and .so to python_source_dir
fluid_proto_binary_path = (
paddle_binary_dir + '/python/paddle/fluid/proto/'
)
fluid_proto_source_path = (
paddle_source_dir + '/python/paddle/fluid/proto/'
)
distributed_proto_binary_path = (
paddle_binary_dir + '/python/paddle/distributed/fleet/proto/'
)
distributed_proto_source_path = (
paddle_source_dir + '/python/paddle/distributed/fleet/proto/'
)
os.system("rm -rf {}".format(fluid_proto_source_path))
shutil.copytree(fluid_proto_binary_path, fluid_proto_source_path)
os.system("rm -rf {}".format(distributed_proto_source_path))
shutil.copytree(
distributed_proto_binary_path, distributed_proto_source_path
)
shutil.copy(
paddle_binary_dir + '/python/paddle/fluid/libpaddle.so',
paddle_source_dir + '/python/paddle/fluid/',
)
dynamic_library_binary_path = paddle_binary_dir + '/python/paddle/libs/'
dynamic_library_source_path = paddle_source_dir + '/python/paddle/libs/'
for lib_so in os.listdir(dynamic_library_binary_path):
shutil.copy(
dynamic_library_binary_path + lib_so,
dynamic_library_source_path,
)
# write version.py and cuda_env_config_py to python_source_dir
write_version_py(
filename='{}/python/paddle/version/__init__.py'.format(
paddle_source_dir
)
)
write_cuda_env_config_py(
filename='{}/python/paddle/cuda_env.py'.format(paddle_source_dir)
)
write_parameter_server_version_py(
filename='{}/python/paddle/incubate/distributed/fleet/parameter_server/version.py'.format(
paddle_source_dir
)
)
DevelopCommandBase.run(self)
class EggInfo(egg_info):
"""Copy license file into `.dist-info` folder."""
......@@ -828,18 +878,7 @@ def get_package_data_and_package_dir():
paddle_binary_dir + '/python/paddle/cost_model/static_op_benchmark.json'
]
if 'develop' in sys.argv:
package_dir = {
'': paddle_binary_dir.split('/')[-1] + '/python',
# '':'build/python',
# The paddle.fluid.proto will be generated while compiling.
# So that package points to other directory.
'paddle.fluid.proto.profiler': paddle_binary_dir.split('/')[-1]
+ '/paddle/fluid/platform',
'paddle.fluid.proto': paddle_binary_dir.split('/')[-1]
+ '/paddle/fluid/framework',
'paddle.fluid': paddle_binary_dir.split('/')[-1]
+ '/python/paddle/fluid',
}
package_dir = {'': 'python'}
else:
package_dir = {
'': env_dict.get("PADDLE_BINARY_DIR") + '/python',
......@@ -1470,6 +1509,7 @@ def main():
# preparing parameters for setup()
paddle_version = env_dict.get("PADDLE_VERSION")
package_name = env_dict.get("PACKAGE_NAME")
write_version_py(
filename='{}/python/paddle/version/__init__.py'.format(
paddle_binary_dir
......@@ -1534,6 +1574,7 @@ def main():
'install': InstallCommand,
'egg_info': EggInfo,
'install_lib': InstallLib,
'develop': DevelopCommand,
},
entry_points={
'console_scripts': [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册