Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit db41933

Browse files
committed
Put scons data into its own class.
1 parent 2822783 commit db41933

3 files changed

Lines changed: 25 additions & 34 deletions

File tree

numpy/distutils/command/scons.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -422,20 +422,22 @@ def _init_cxxcompiler(self, compiler_type):
422422

423423
def finalize_options(self):
424424
old_build_ext.finalize_options(self)
425+
426+
self.sconscripts = []
427+
self.pre_hooks = []
428+
self.post_hooks = []
429+
self.pkg_names = []
430+
425431
if self.distribution.has_scons_scripts():
426-
self.sconscripts = self.distribution.get_scons_scripts()
427-
self.pre_hooks = self.distribution.get_scons_pre_hooks()
428-
self.post_hooks = self.distribution.get_scons_post_hooks()
429-
self.pkg_names = self.distribution.get_scons_parent_names()
432+
for i in self.distribution.scons_data:
433+
self.sconscripts.append(i.scons_path)
434+
self.pre_hooks.append(i.pre_hook)
435+
self.post_hooks.append(i.post_hook)
436+
self.pkg_names.append(i.parent_name)
430437
# This crap is needed to get the build_clib
431438
# directory
432439
build_clib_cmd = get_cmd("build_clib").get_finalized_command("build_clib")
433440
self.build_clib = build_clib_cmd.build_clib
434-
else:
435-
self.sconscripts = []
436-
self.pre_hooks = []
437-
self.post_hooks = []
438-
self.pkg_names = []
439441

440442
if not self.cxxcompiler:
441443
self.cxxcompiler = self.compiler

numpy/distutils/misc_util.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,15 @@ def get_frame(level=0):
590590
frame = frame.f_back
591591
return frame
592592

593+
class SconsInfo(object):
594+
def __init__(self, scons_path, parent_name, pre_hook,
595+
post_hook, source_files):
596+
self.scons_path = scons_path
597+
self.parent_name = parent_name
598+
self.pre_hook = pre_hook
599+
self.post_hook = post_hook
600+
self.source_files = source_files
601+
593602
######################
594603

595604
class Configuration(object):
@@ -1542,23 +1551,18 @@ def add_sconscript(self, sconscript, subpackage_path=None,
15421551
if source_files:
15431552
full_source_files.extend([self.paths(i)[0] for i in source_files])
15441553

1554+
scons_info = SconsInfo(fullsconsname, parent_name,
1555+
pre_hook, post_hook,
1556+
full_source_files)
15451557
if dist is not None:
1546-
dist.scons_data.append((fullsconsname,
1547-
pre_hook,
1548-
post_hook,
1549-
full_source_files,
1550-
parent_name))
1558+
dist.scons_data.append(scons_info)
15511559
self.warn('distutils distribution has been initialized,'\
15521560
' it may be too late to add a subpackage '+ subpackage_name)
15531561
# XXX: we add a fake extension, to correctly initialize some
15541562
# options in distutils command.
15551563
dist.add_extension('', sources = [])
15561564
else:
1557-
self.scons_data.append((fullsconsname,
1558-
pre_hook,
1559-
post_hook,
1560-
full_source_files,
1561-
parent_name))
1565+
self.scons_data.append(scons_info)
15621566
# XXX: we add a fake extension, to correctly initialize some
15631567
# options in distutils command.
15641568
self.add_extension('', sources = [])

numpy/distutils/numpy_distribution.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,3 @@ def __init__(self, attrs = None):
1515

1616
def has_scons_scripts(self):
1717
return bool(self.scons_data)
18-
19-
def get_scons_scripts(self):
20-
return [i[0] for i in self.scons_data]
21-
22-
def get_scons_pre_hooks(self):
23-
return [i[1] for i in self.scons_data]
24-
25-
def get_scons_post_hooks(self):
26-
return [i[2] for i in self.scons_data]
27-
28-
def get_scons_sources(self):
29-
return [i[3] for i in self.scons_data]
30-
31-
def get_scons_parent_names(self):
32-
return [i[4] for i in self.scons_data]

0 commit comments

Comments
 (0)