Permalink
Browse files

Add a pkg_path option to add_sconcript.

This is necessary to handle some cases where scons scripts and packages
are not in the same directory.
  • Loading branch information...
1 parent db41933 commit 5932ddd5cbd9c756b0b8ab8a4b1ea690b1bb1a7b @cournape cournape committed Oct 1, 2009
Showing with 19 additions and 7 deletions.
  1. +9 −4 numpy/distutils/command/scons.py
  2. +10 −3 numpy/distutils/misc_util.py
@@ -427,13 +427,15 @@ def finalize_options(self):
self.pre_hooks = []
self.post_hooks = []
self.pkg_names = []
+ self.pkg_paths = []
if self.distribution.has_scons_scripts():
for i in self.distribution.scons_data:
self.sconscripts.append(i.scons_path)
self.pre_hooks.append(i.pre_hook)
self.post_hooks.append(i.post_hook)
self.pkg_names.append(i.parent_name)
+ self.pkg_paths.append(i.pkg_path)
# This crap is needed to get the build_clib
# directory
build_clib_cmd = get_cmd("build_clib").get_finalized_command("build_clib")
@@ -467,7 +469,7 @@ def finalize_options(self):
if self.package_list:
self.package_list = parse_package_list(self.package_list)
- def _call_scons(self, scons_exec, sconscript, pkg_name, bootstrapping):
+ def _call_scons(self, scons_exec, sconscript, pkg_name, pkg_path, bootstrapping):
# XXX: when a scons script is missing, scons only prints warnings, and
# does not return a failure (status is 0). We have to detect this from
# distutils (this cannot work for recursive scons builds...)
@@ -483,6 +485,7 @@ def _call_scons(self, scons_exec, sconscript, pkg_name, bootstrapping):
cmd.append("inplace=1")
cmd.append('scons_tool_path="%s"' % self.scons_tool_path)
cmd.append('src_dir="%s"' % pdirname(sconscript))
+ cmd.append('pkg_path="%s"' % pkg_path)
cmd.append('pkg_name="%s"' % pkg_name)
cmd.append('log_level=%s' % self.log_level)
#cmd.append('distutils_libdir=%s' % protect_path(pjoin(self.build_lib,
@@ -553,11 +556,13 @@ def run(self):
pre_hooks = [self.pre_hooks[i] for i in id]
post_hooks = [self.post_hooks[i] for i in id]
pkg_names = [self.pkg_names[i] for i in id]
+ pkg_paths = [self.pkg_names[i] for i in id]
else:
sconscripts = self.sconscripts
pre_hooks = self.pre_hooks
post_hooks = self.post_hooks
pkg_names = self.pkg_names
+ pkg_paths = self.pkg_paths
if is_bootstrapping():
bootstrapping = 1
@@ -567,14 +572,14 @@ def run(self):
scons_exec = get_python_exec_invoc()
scons_exec += ' ' + protect_path(pjoin(get_scons_local_path(), 'scons.py'))
- for sconscript, pre_hook, post_hook, pkg_name in zip(sconscripts,
+ for sconscript, pre_hook, post_hook, pkg_name, pkg_path in zip(sconscripts,
pre_hooks, post_hooks,
- pkg_names):
+ pkg_names, pkg_paths):
if pre_hook:
pre_hook()
if sconscript:
- self._call_scons(scons_exec, sconscript, pkg_name, bootstrapping)
+ self._call_scons(scons_exec, sconscript, pkg_name, pkg_path, bootstrapping)
if post_hook:
post_hook(**{'pkg_name': pkg_name, 'scons_cmd' : self})
@@ -592,12 +592,19 @@ def get_frame(level=0):
class SconsInfo(object):
def __init__(self, scons_path, parent_name, pre_hook,
- post_hook, source_files):
+ post_hook, source_files, pkg_path):
self.scons_path = scons_path
self.parent_name = parent_name
self.pre_hook = pre_hook
self.post_hook = post_hook
self.source_files = source_files
+ if pkg_path:
+ self.pkg_path = pkg_path
+ else:
+ if scons_path:
+ self.pkg_path = os.path.dirname(scons_path)
+ else:
+ self.pkg_path = ''
######################
@@ -1526,7 +1533,7 @@ def add_scons_installed_library(self, name, install_dir):
def add_sconscript(self, sconscript, subpackage_path=None,
standalone = False, pre_hook = None,
- post_hook = None, source_files = None):
+ post_hook = None, source_files = None, package_path=None):
"""Add a sconscript to configuration.
pre_hook and post hook should be sequences of callable, which will be
@@ -1553,7 +1560,7 @@ def add_sconscript(self, sconscript, subpackage_path=None,
scons_info = SconsInfo(fullsconsname, parent_name,
pre_hook, post_hook,
- full_source_files)
+ full_source_files, package_path)
if dist is not None:
dist.scons_data.append(scons_info)
self.warn('distutils distribution has been initialized,'\

0 comments on commit 5932ddd

Please sign in to comment.