diff --git a/python/.gitignore b/python/.gitignore index 53a2b7a76b0dd2d9095f9582540e455e2c1174e2..d0c7300f8c443f821543704976e2c81b2b540be2 100644 --- a/python/.gitignore +++ b/python/.gitignore @@ -7,3 +7,4 @@ paddlepaddle_gpu.egg-info .idea paddle/proto/*.py paddle/proto/*.pyc +_foo.* diff --git a/python/paddle/.gitignore b/python/paddle/.gitignore index 98527864664d32f798edc06a53131e8d5a068295..b405a11db9a8df2e686bb1cb15276020b60e7fe1 100644 --- a/python/paddle/.gitignore +++ b/python/paddle/.gitignore @@ -1 +1,3 @@ version.py +cuda_env.py +version diff --git a/python/paddle/distributed/fleet/.gitignore b/python/paddle/distributed/fleet/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..2ff540d5764b76cf7bac64fc2bb9df6e9c1b398a --- /dev/null +++ b/python/paddle/distributed/fleet/.gitignore @@ -0,0 +1 @@ +proto diff --git a/python/paddle/fluid/.gitignore b/python/paddle/fluid/.gitignore index 80c1cf3fcb86aa50600e02e4765640a91560916e..0745bad8c6791b799ff01729c782736882162107 100644 --- a/python/paddle/fluid/.gitignore +++ b/python/paddle/fluid/.gitignore @@ -1,2 +1,3 @@ proto core.so +*.so diff --git a/python/paddle/libs/.gitignore b/python/paddle/libs/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..8d977535b81865b47946db403e71c50f35039abe --- /dev/null +++ b/python/paddle/libs/.gitignore @@ -0,0 +1 @@ +*.so* diff --git a/setup.py b/setup.py index 75969c5f41cbba1ff5e98fe8f7452d7efc8c12ab..c4137d4222747dad8545f867850c4c40d88c7ae3 100644 --- a/setup.py +++ b/setup.py @@ -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': [