Skip to content

Commit

Permalink
Fix for widget when 'install' is run separately on src data from sdis…
Browse files Browse the repository at this point in the history
…t.,. #830, #2242, #2278
  • Loading branch information
andrey-khropov committed Mar 30, 2023
1 parent 4d95f41 commit 3896117
Showing 1 changed file with 38 additions and 7 deletions.
45 changes: 38 additions & 7 deletions catboost/python-package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import sys
from typing import Dict, List
from distutils.command.bdist import bdist as _bdist
from distutils.command.install_data import install_data as _install_data
from distutils import log

# requires setuptools >= 64.0.0
Expand Down Expand Up @@ -522,6 +523,26 @@ def run(self):

self._build(verbose, dry_run)

class install_data(_install_data):
extra_options_classes = [WidgetOptions]

user_options = _install.user_options + OptionsHelper.get_user_options(extra_options_classes)

def initialize_options(self):
_install_data.initialize_options(self)
OptionsHelper.initialize_options(self)

def finalize_options(self):
_install_data.finalize_options(self)
OptionsHelper.finalize_options(self)
if not self.no_widget:
if self.data_files is None:
self.data_files = []
self.data_files += self.get_finalized_command("build_widget").get_data_files(
dry_run=self.distribution.dry_run
)


class install(_install):
extra_options_classes = [HNSWOptions, WidgetOptions, BuildExtOptions]

Expand All @@ -535,23 +556,32 @@ def finalize_options(self):
_install.finalize_options(self)
OptionsHelper.finalize_options(self)

def run(self):
if not self.no_widget:
if self.distribution.data_files is None:
self.distribution.data_files = []
self.distribution.data_files += self.get_finalized_command("build_widget").get_data_files(
dry_run=self.distribution.dry_run
)
def has_data(self):
return super().has_data() or (not self.no_widget)

def run(self):
OptionsHelper.propagate(
self,
"build",
HNSWOptions.get_options_attribute_names()
+ WidgetOptions.get_options_attribute_names()
+ BuildExtOptions.get_options_attribute_names()
)
OptionsHelper.propagate(
self,
"install_data",
WidgetOptions.get_options_attribute_names()
)
_install.run(self)

sub_commands = [
('install_lib', _install.has_lib),
('install_headers', _install.has_headers),
('install_scripts', _install.has_scripts),
('install_data', has_data),
('install_egg_info', lambda self:True),
]

class sdist(_sdist):

def make_release_tree(self, base_dir, files):
Expand Down Expand Up @@ -594,6 +624,7 @@ def make_release_tree(self, base_dir, files):
'build_widget': build_widget,
'build': build,
'install': install,
'install_data': install_data,
'sdist': sdist,
},
extras_require={
Expand Down

0 comments on commit 3896117

Please sign in to comment.