From f16087e09ce60938aef324e661237190100d2568 Mon Sep 17 00:00:00 2001 From: pangyoki Date: Mon, 25 Apr 2022 10:43:36 +0800 Subject: [PATCH] Cherry-pick PR42187, add LICENSE in wheel dist-info package (#42187) --- python/setup.py.in | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/python/setup.py.in b/python/setup.py.in index e4637444be1..0f231e34168 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': [ -- GitLab