This action will force synchronization from PaddlePaddle/Paddle, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
import subprocessimport osimport os.pathimport errnoimport reimport shutilimport sysimport fnmatchimport errnoimport platformfrom contextlib import contextmanagerfrom setuptools import Commandfrom setuptools import setup, Distribution, Extensionfrom setuptools.command.install import install as InstallCommandBaseclass BinaryDistribution(Distribution):def has_ext_modules(foo):return TrueRC = 0ext_name = '.dll' if os.name == 'nt' else ('.dylib' if sys.platform == 'darwin' else '.so')def git_commit():try:cmd = ['git', 'rev-parse', 'HEAD']git_commit = subprocess.Popen(cmd, stdout = subprocess.PIPE,cwd="@PADDLE_SOURCE_DIR@").communicate()[0].strip()except:git_commit = 'Unknown'git_commit = git_commit.decode()return str(git_commit)def _get_version_detail(idx):assert idx < 3, "vesion info consists of %(major)d.%(minor)d.%(patch)d, \so detail index must less than 3"if re.match('@TAG_VERSION_REGEX@', '@PADDLE_VERSION@'):version_details = '@PADDLE_VERSION@'.split('.')if len(version_details) >= 3:return version_details[idx]return 0def get_major():return int(_get_version_detail(0))def get_minor():return int(_get_version_detail(1))def get_patch():return str(_get_version_detail(2))def is_taged():try:cmd = ['git', 'describe', '--exact-match', '--tags', 'HEAD', '2>/dev/null']git_tag = subprocess.Popen(cmd, stdout = subprocess.PIPE, cwd="@PADDLE_SOURCE_DIR@").communicate()[0].strip()git_tag = git_tag.decode()except:return Falseif str(git_tag).replace('v', '') == '@PADDLE_VERSION@':return Trueelse:return Falsedef write_version_py(filename='paddle/version.py'):cnt = '''# THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PY#full_version = '%(major)d.%(minor)d.%(patch)s'major = '%(major)d'minor = '%(minor)d'patch = '%(patch)s'rc = '%(rc)d'istaged = %(istaged)scommit = '%(commit)s'with_mkl = '%(with_mkl)s'def show():if istaged:print('full_version:', full_version)print('major:', major)print('minor:', minor)print('patch:', patch)print('rc:', rc)else:print('commit:', commit)def mkl():return with_mkl'''commit = git_commit()with open(filename, 'w') as f:f.write(cnt % {'major': get_major(),'minor': get_minor(),'patch': get_patch(),'rc': RC,'version': '${PADDLE_VERSION}','commit': commit,'istaged': is_taged(),'with_mkl': '@WITH_MKL@'})write_version_py(filename='@PADDLE_BINARY_DIR@/python/paddle/version.py')def write_distributed_training_mode_py(filename='paddle/fluid/incubate/fleet/parameter_server/version.py'):cnt = '''from __future__ import print_function# THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PYfrom paddle.fluid.incubate.fleet.base.mode import ModeBUILD_MODE=Mode.%(mode)sdef is_transpiler():return Mode.TRANSPILER == BUILD_MODE'''dirname = os.path.dirname(filename)try:os.makedirs(dirname)except OSError as e:if e.errno != errno.EEXIST:raisewith open(filename, 'w') as f:f.write(cnt % {'mode': 'PSLIB' if '${WITH_PSLIB}' == 'ON' else 'TRANSPILER'})write_distributed_training_mode_py(filename='@PADDLE_BINARY_DIR@/python/paddle/fluid/incubate/fleet/parameter_server/version.py')packages=['paddle','paddle.libs','paddle.utils','paddle.dataset','paddle.reader','paddle.distributed','paddle.incubate','paddle.distributed.fleet','paddle.distributed.fleet.base','paddle.distributed.fleet.meta_optimizers','paddle.distributed.fleet.meta_optimizers.sharding','paddle.distributed.fleet.runtime','paddle.distributed.fleet.dataset','paddle.distributed.fleet.data_generator','paddle.distributed.fleet.metrics','paddle.distributed.fleet.proto','paddle.distributed.fleet.utils','paddle.framework','paddle.jit','paddle.jit.dy2static','paddle.inference','paddle.fluid','paddle.fluid.inference','paddle.fluid.dygraph','paddle.fluid.dygraph.dygraph_to_static','paddle.fluid.dygraph.amp','paddle.fluid.proto','paddle.fluid.proto.profiler','paddle.fluid.distributed','paddle.fluid.layers','paddle.fluid.dataloader','paddle.fluid.contrib','paddle.fluid.contrib.decoder','paddle.fluid.contrib.quantize','paddle.fluid.contrib.reader','paddle.fluid.contrib.slim','paddle.fluid.contrib.slim.quantization','paddle.fluid.contrib.slim.quantization.imperative','paddle.fluid.contrib.utils','paddle.fluid.contrib.extend_optimizer','paddle.fluid.contrib.mixed_precision','paddle.fluid.contrib.layers','paddle.fluid.transpiler','paddle.fluid.transpiler.details','paddle.fluid.incubate','paddle.fluid.incubate.data_generator','paddle.fluid.incubate.fleet','paddle.fluid.incubate.checkpoint','paddle.fluid.incubate.fleet.base','paddle.fluid.incubate.fleet.parameter_server','paddle.fluid.incubate.fleet.parameter_server.distribute_transpiler','paddle.fluid.incubate.fleet.parameter_server.pslib','paddle.fluid.incubate.fleet.parameter_server.ir','paddle.fluid.incubate.fleet.collective','paddle.fluid.incubate.fleet.utils','paddle.amp','paddle.hapi','paddle.vision','paddle.vision.models','paddle.vision.transforms','paddle.vision.datasets','paddle.text','paddle.text.datasets','paddle.incubate','paddle.io','paddle.optimizer','paddle.nn','paddle.nn.functional','paddle.nn.layer','paddle.nn.initializer','paddle.nn.utils','paddle.metric','paddle.static','paddle.static.nn','paddle.static.amp','paddle.tensor','paddle.onnx',]with open('@PADDLE_SOURCE_DIR@/python/requirements.txt') as f:setup_requires = f.read().splitlines()# Note(wangzhongpu):# When compiling paddle under python36, the dependencies belonging to python2.7 will be imported, resulting in errors when installing paddleif sys.version_info >= (3,6) and sys.version_info < (3,7):setup_requires_tmp = []for setup_requires_i in setup_requires:if "<\"3.6\"" in setup_requires_i or "<\"3.5\"" in setup_requires_i or "<=\"3.5\"" in setup_requires_i:continuesetup_requires_tmp+=[setup_requires_i]setup_requires = setup_requires_tmpif sys.version_info >= (3,5) and sys.version_info < (3,6):setup_requires_tmp = []for setup_requires_i in setup_requires:if "<\"3.5\"" in setup_requires_i:continuesetup_requires_tmp+=[setup_requires_i]setup_requires = setup_requires_tmpif sys.version_info >= (3,7):setup_requires_tmp = []for setup_requires_i in setup_requires:if "<\"3.6\"" in setup_requires_i or "<=\"3.6\"" in setup_requires_i or "<\"3.5\"" in setup_requires_i or "<=\"3.5\"" in setup_requires_i or "<\"3.7\"" in setup_requires_i:continuesetup_requires_tmp+=[setup_requires_i]setup_requires = setup_requires_tmp# the prefix is sys.prefix which should always be usrpaddle_bins = ''if not '${WIN32}':paddle_bins = ['${PADDLE_BINARY_DIR}/paddle/scripts/paddle']package_data={'paddle.fluid': ['${FLUID_CORE_NAME}' + ('.so' if os.name != 'nt' else '.pyd')]}if '${HAS_NOAVX_CORE}' == 'ON':package_data['paddle.fluid'] += ['core_noavx' + ('.so' if os.name != 'nt' else '.pyd')]package_dir={'': '${PADDLE_BINARY_DIR}/python',# The paddle.fluid.proto will be generated while compiling.# So that package points to other directory.'paddle.fluid.proto.profiler': '${PADDLE_BINARY_DIR}/paddle/fluid/platform','paddle.fluid.proto': '${PADDLE_BINARY_DIR}/paddle/fluid/framework','paddle.fluid': '${PADDLE_BINARY_DIR}/python/paddle/fluid',}# put all thirdparty libraries in paddle.libslibs_path='${PADDLE_BINARY_DIR}/python/paddle/libs'package_data['paddle.libs']= []package_data['paddle.libs']=[('libwarpctc' if os.name != 'nt' else 'warpctc') + ext_name]shutil.copy('${WARPCTC_LIBRARIES}', libs_path)if '${WITH_MKL}' == 'ON':shutil.copy('${MKLML_SHARED_LIB}', libs_path)shutil.copy('${MKLML_SHARED_IOMP_LIB}', libs_path)package_data['paddle.libs']+=[('libmklml_intel' if os.name != 'nt' else 'mklml') + ext_name, ('libiomp5' if os.name != 'nt' else 'libiomp5md') + ext_name]else:if os.name == 'nt':# copy the openblas.dllshutil.copy('${OPENBLAS_SHARED_LIB}', libs_path)package_data['paddle.libs'] += ['openblas' + ext_name]if '${WITH_LITE}' == 'ON':shutil.copy('${LITE_SHARED_LIB}', libs_path)package_data['paddle.libs']+=['libpaddle_full_api_shared' + ext_name]if '${WITH_PSLIB}' == 'ON':shutil.copy('${PSLIB_LIB}', libs_path)if os.path.exists('${PSLIB_VERSION_PY}'):shutil.copy('${PSLIB_VERSION_PY}', '${PADDLE_BINARY_DIR}/python/paddle/fluid/incubate/fleet/parameter_server/pslib/')package_data['paddle.libs'] += ['libps' + ext_name]if '${WITH_MKLDNN}' == 'ON':if '${CMAKE_BUILD_TYPE}' == 'Release' and os.name != 'nt':# only change rpath in Release mode.# TODO(typhoonzero): use install_name_tool to patch mkl libs once# we can support mkl on mac.## change rpath of libdnnl.so.1, add $ORIGIN/ to it.# The reason is that all thirdparty libraries in the same directory,# thus, libdnnl.so.1 will find libmklml_intel.so and libiomp5.so.command = "patchelf --set-rpath '$ORIGIN/' ${MKLDNN_SHARED_LIB}"if os.system(command) != 0:raise Exception("patch libdnnl.so failed, command: %s" % command)shutil.copy('${MKLDNN_SHARED_LIB}', libs_path)if os.name != 'nt':shutil.copy('${MKLDNN_SHARED_LIB_1}', libs_path)package_data['paddle.libs']+=['libmkldnn.so.0', 'libdnnl.so.1']else:package_data['paddle.libs']+=['mkldnn.dll']if '${WITH_XPU}' == 'ON':# only change rpath in Release mode,if '${CMAKE_BUILD_TYPE}' == 'Release':if os.name != 'nt':if "@APPLE@" == "1":command = "install_name_tool -id \"@loader_path/\" ${XPU_API_LIB}"else:command = "patchelf --set-rpath '$ORIGIN/' ${XPU_API_LIB}"if os.system(command) != 0:raise Exception("patch ${XPU_API_LIB} failed, command: %s" % command)shutil.copy('${XPU_API_LIB}', libs_path)shutil.copy('${XPU_RT_LIB}', libs_path)package_data['paddle.libs']+=['${XPU_API_LIB_NAME}','${XPU_RT_LIB_NAME}']# copy libfuild_framework.so to libsif os.name != 'nt' and sys.platform != 'darwin':paddle_framework_lib='${FLUID_FRAMEWORK_SHARED_LIB}'shutil.copy(paddle_framework_lib, libs_path)package_data['paddle.libs'] += [('libpaddle_framework' if os.name != 'nt' else 'paddle_framework') + ext_name]# remove unused paddle/libs/__init__.pyif os.path.isfile(libs_path+'/__init__.py'):os.remove(libs_path+'/__init__.py')package_dir['paddle.libs']=libs_path# change rpath of ${FLUID_CORE_NAME}.ext, add $ORIGIN/../libs/ to it.# The reason is that libwarpctc.ext, libiomp5.ext etc are in paddle.libs, and# ${FLUID_CORE_NAME}.ext is in paddle.fluid, thus paddle/fluid/../libs will pointer to above libraries.# This operation will fix https://github.com/PaddlePaddle/Paddle/issues/3213if '${CMAKE_BUILD_TYPE}' == 'Release':if os.name != 'nt':# only change rpath in Release mode, since in Debug mode, ${FLUID_CORE_NAME}.xx is too large to be changed.if "@APPLE@" == "1":command = "install_name_tool -id \"@loader_path/../libs/\" ${PADDLE_BINARY_DIR}/python/paddle/fluid/${FLUID_CORE_NAME}" + '.so'else:command = "patchelf --set-rpath '$ORIGIN/../libs/' ${PADDLE_BINARY_DIR}/python/paddle/fluid/${FLUID_CORE_NAME}" + '.so'# The dynamic library compiled under aarch64 is greater than 64M,# and an oversize error will be reported when using patchelf.# The sw_64 not suppot patchelf, so we just disable that.if platform.machine() != 'aarch64' and platform.machine() != 'sw_64':if os.system(command) != 0:raise Exception("patch ${FLUID_CORE_NAME}.%s failed, command: %s" % (ext_name, command))ext_modules = [Extension('_foo', ['stub.cc'])]if os.name == 'nt':# fix the path separator under windowsfix_package_dir = {}for k, v in package_dir.items():fix_package_dir[k] = v.replace('/', '\\')package_dir = fix_package_dirext_modules = []elif sys.platform == 'darwin':ext_modules = []def find_files(pattern, root):for dirpath, _, files in os.walk(root):for filename in fnmatch.filter(files, pattern):yield os.path.join(dirpath, filename)headers = (list(find_files('*.h', '@PADDLE_SOURCE_DIR@/paddle/fluid/framework')) +list(find_files('*.h', '@PADDLE_SOURCE_DIR@/paddle/fluid/imperative')) +list(find_files('*.h', '@PADDLE_SOURCE_DIR@/paddle/fluid/memory')) +list(find_files('*.h', '@PADDLE_SOURCE_DIR@/paddle/fluid/platform')) +list(find_files('*.h', '@PADDLE_SOURCE_DIR@/paddle/fluid/string')) +list(find_files('*.pb.h', '${PADDLE_BINARY_DIR}/paddle/fluid/platform')) +list(find_files('*.pb.h', '${PADDLE_BINARY_DIR}/paddle/fluid/framework')) +list(find_files('*.pb', '${cudaerror_INCLUDE_DIR}')) + # errorMessage.pb for errormessage['${EIGEN_INCLUDE_DIR}/Eigen/Core'] + # eigenlist(find_files('*', '${EIGEN_INCLUDE_DIR}/Eigen/src')) + # eigenlist(find_files('*', '${EIGEN_INCLUDE_DIR}/unsupported/Eigen')) + # eigenlist(find_files('*', '${GFLAGS_INSTALL_DIR}/include')) + # gflagslist(find_files('*', '${GLOG_INSTALL_DIR}/include')) + # gloglist(find_files('*', '${BOOST_INCLUDE_DIR}/boost')) + # boostlist(find_files('*', '${XXHASH_INSTALL_DIR}/include')) + # xxhashlist(find_files('*', '${PROTOBUF_INCLUDE_DIR}')) + # protobuflist(find_files('*', '${DLPACK_INCLUDE_DIR}')) + # dlpacklist(find_files('*.h', '${THREADPOOL_INCLUDE_DIR}'))) # threadpoolif '${WITH_MKLDNN}' == 'ON':headers += list(find_files('*', '${MKLDNN_INSTALL_DIR}/include')) # mkldnnif '${WITH_GPU}' == 'ON':headers += list(find_files('*.pb', '${cudaerror_INCLUDE_DIR}')) # errorMessage.pb for errormessageclass InstallCommand(InstallCommandBase):def finalize_options(self):ret = InstallCommandBase.finalize_options(self)self.install_headers = os.path.join(self.install_purelib, 'paddle','include')self.install_lib = self.install_platlibreturn retclass InstallHeaders(Command):"""Override how headers are copied."""description = 'install C/C++ header files'user_options = [('install-dir=', 'd','directory to install header files to'),('force', 'f','force installation (overwrite existing files)'),]boolean_options = ['force']def initialize_options(self):self.install_dir = Noneself.force = 0self.outfiles = []def finalize_options(self):self.set_undefined_options('install',('install_headers', 'install_dir'),('force', 'force'))def mkdir_and_copy_file(self, header):if 'pb.h' in header:install_dir = re.sub('${PADDLE_BINARY_DIR}/', '', header)elif 'third_party' not in header:# frameworkinstall_dir = re.sub('@PADDLE_SOURCE_DIR@/', '', header)else:# third_partyinstall_dir = re.sub('${THIRD_PARTY_PATH}', 'third_party', header)patterns = ['eigen3/src/extern_eigen3', 'boost/src/extern_boost','dlpack/src/extern_dlpack/include','install/protobuf/include','install/gflags/include','install/glog/include', 'install/xxhash/include','install/mkldnn/include','threadpool/src/extern_threadpool']for pattern in patterns:install_dir = re.sub(pattern, '', install_dir)install_dir = os.path.join(self.install_dir, os.path.dirname(install_dir))if not os.path.exists(install_dir):self.mkpath(install_dir)return self.copy_file(header, install_dir)def run(self):# only copy third_party/cudaErrorMessage.pb for cudaErrorMessage on mac or windowsif os.name == 'nt' or sys.platform == 'darwin':if '${WITH_GPU}' == 'ON':self.mkdir_and_copy_file('${cudaerror_INCLUDE_DIR}/cudaErrorMessage.pb')returnhdrs = self.distribution.headersif not hdrs:returnself.mkpath(self.install_dir)for header in hdrs:(out, _) = self.mkdir_and_copy_file(header)self.outfiles.append(out)def get_inputs(self):return self.distribution.headers or []def get_outputs(self):return self.outfiles# we redirect setuptools log for non-windowsif sys.platform != 'win32':@contextmanagerdef redirect_stdout():f_log = open('${SETUP_LOG_FILE}', 'w')origin_stdout = sys.stdoutsys.stdout = f_logyieldf_log = sys.stdoutsys.stdout = origin_stdoutf_log.close()else:@contextmanagerdef redirect_stdout():yieldwith redirect_stdout():setup(name='${PACKAGE_NAME}',version='${PADDLE_VERSION}',description='Parallel Distributed Deep Learning',install_requires=setup_requires,packages=packages,ext_modules=ext_modules,package_data=package_data,package_dir=package_dir,scripts=paddle_bins,distclass=BinaryDistribution,headers=headers,cmdclass={'install_headers': InstallHeaders,'install': InstallCommand,},entry_points={'console_scripts': ['fleetrun = paddle.distributed.fleet.launch:launch']})# As there are a lot of files in purelib which causes many logs,# we don't print them on the screen, and you can open `setup.py.log`# for the full logs.if os.path.exists('${SETUP_LOG_FILE}'):os.system('grep -v "purelib" ${SETUP_LOG_FILE}')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。