diff --git a/python/setup.py.in b/python/setup.py.in index e4637444be171aa64ff88fc19c71240ca844ea7e..0f231e34168d99b2468fc2d4b5e3f2090d034778 100755 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -13,6 +13,7 @@ from contextlib import contextmanager from setuptools import Command from setuptools import setup, Distribution, Extension from setuptools.command.install import install as InstallCommandBase +from setuptools.command.egg_info import egg_info class BinaryDistribution(Distribution): @@ -678,6 +679,17 @@ class InstallHeaders(Command): def get_outputs(self): return self.outfiles +class EggInfo(egg_info): + """Copy license file into `.dist-info` folder.""" + + def run(self): + # don't duplicate license into `.dist-info` when building a distribution + if not self.distribution.have_run.get('install', True): + self.mkpath(self.egg_info) + self.copy_file("@PADDLE_SOURCE_DIR@/LICENSE", self.egg_info) + + egg_info.run(self) + # we redirect setuptools log for non-windows if sys.platform != 'win32': @contextmanager @@ -733,6 +745,7 @@ with redirect_stdout(): cmdclass={ 'install_headers': InstallHeaders, 'install': InstallCommand, + 'egg_info': EggInfo, }, entry_points={ 'console_scripts': [