summaryrefslogtreecommitdiff
path: root/weave/build_tools.py
diff options
context:
space:
mode:
authorEric Jones <eric@enthought.com>2002-09-19 07:08:30 +0000
committerEric Jones <eric@enthought.com>2002-09-19 07:08:30 +0000
commit200bff5384ca06d4d61570a576f94ff63b6c335d (patch)
tree780842aff1bceab242543194ef9bbb6b0044b5c8 /weave/build_tools.py
parent9dec5004a2593a123fb80eefcb5d73a229cb7501 (diff)
downloadnumpy-200bff5384ca06d4d61570a576f94ff63b6c335d.tar.gz
added yet another directory into the path of intermediate files generated by
weave. This is needed so that people switching between compilers don't end up trying to link c++ object files built with incompatible compilers together. changed Py_INCREF to a Py_XINCREF to guard against NULL pointer problems in convert_to_xxx routines. lengthened the type_names strings for Numeric type names in standard_array_spec. It was shorter than some of the names. yikes! choose_compiler stuff is no longer done by ext_modules. This was used to allow xxx_convterters and xxx_info objects to generate different code depending on which compiler was used. This is no longer done, and I don't think it should be necessary going forward. I've left a little of the code in case I'm wrong, but will probably hack it out soon.
Diffstat (limited to 'weave/build_tools.py')
-rw-r--r--weave/build_tools.py38
1 files changed, 36 insertions, 2 deletions
diff --git a/weave/build_tools.py b/weave/build_tools.py
index 1e931dd96..23385fa6f 100644
--- a/weave/build_tools.py
+++ b/weave/build_tools.py
@@ -24,6 +24,7 @@ import exceptions
# If linker is 'gcc', this will convert it to 'g++'
# necessary to make sure stdc++ is linked in cross-platform way.
import distutils.sysconfig
+import distutils.dir_util
old_init_posix = distutils.sysconfig._init_posix
@@ -146,12 +147,22 @@ def build_extension(module_path,compiler_name = '',build_dir = None,
# get the name of the module and the extension directory it lives in.
module_dir,cpp_name = os.path.split(os.path.abspath(module_path))
module_name,ext = os.path.splitext(cpp_name)
-
+
# configure temp and build directories
temp_dir = configure_temp_dir(temp_dir)
build_dir = configure_build_dir(module_dir)
+ # dag. We keep having to add directories to the path to keep
+ # object files separated from each other. gcc2.x and gcc3.x C++
+ # object files are not compatible, so we'll stick them in a sub
+ # dir based on their version. This will add gccX.X to the
+ # path.
+ compiler_dir = get_compiler_dir(compiler_name)
+ temp_dir = os.path.join(temp_dir,compiler_dir)
+ distutils.dir_util.mkpath(temp_dir)
+
compiler_name = choose_compiler(compiler_name)
+
configure_sys_argv(compiler_name,temp_dir,build_dir)
# the business end of the function
@@ -298,6 +309,29 @@ def msvc_exists():
result = 1
return result
+if os.name == 'nt':
+ def run_command(command):
+ """ not sure how to get exit status on nt. """
+ in_pipe,out_pipe = os.popen4(command)
+ in_pipe.close()
+ text = out_pipe.read()
+ return 0, text
+else:
+ run_command = commands.getstatusoutput
+
+def get_compiler_dir(compiler_name):
+ if compiler_name == 'gcc':
+ status, text = run_command(compiler_name + ' --version')
+ try:
+ import re
+ version = re.findall('\d\.\d',text)[0]
+ except IndexError:
+ version = ''
+ compiler_dir = compiler_name + version
+ else:
+ compiler_dir = compiler_name
+ return compiler_dir
+
def configure_temp_dir(temp_dir=None):
if temp_dir is None:
temp_dir = tempfile.gettempdir()
@@ -418,7 +452,7 @@ if sys.platform == 'win32':
def build_import_library():
""" Build the import libraries for Mingw32-gcc on Windows
"""
- import scipy_distutils import lib2def
+ from scipy_distutils import lib2def
#libfile, deffile = parse_cmd()
#if deffile is None:
# deffile = sys.stdout