diff options
| author | Charles Harris <charlesr.harris@gmail.com> | 2013-01-13 10:04:44 -0700 |
|---|---|---|
| committer | Charles Harris <charlesr.harris@gmail.com> | 2013-01-13 11:16:47 -0700 |
| commit | df259db01ecf69d518fffd398dd6fb5cf60f1ba1 (patch) | |
| tree | a7a7a7f6b9a5a80759576faa9e61cca97c58cefe /numpy/core | |
| parent | 23e9f01f54474503f0296e3ff1cb173c6228cb98 (diff) | |
| download | numpy-df259db01ecf69d518fffd398dd6fb5cf60f1ba1.tar.gz | |
DEP: Remove scons related files and code.
This removes files and code supporting scons builds. After this change
numpy will only support builds using distutils or bento. The removal of
scons has been discussed on the list several times and a decision has been
made that scons support is no longer needed. This was originally discussed
for numpy 1.7 and because the distutils and bento methods are still
available we are skipping the usual deprecation period.
Diffstat (limited to 'numpy/core')
| -rw-r--r-- | numpy/core/SConscript | 531 | ||||
| -rw-r--r-- | numpy/core/SConstruct | 2 | ||||
| -rw-r--r-- | numpy/core/scons_support.py | 272 | ||||
| -rw-r--r-- | numpy/core/setup_common.py | 2 | ||||
| -rw-r--r-- | numpy/core/setupscons.py | 111 |
5 files changed, 1 insertions, 917 deletions
diff --git a/numpy/core/SConscript b/numpy/core/SConscript deleted file mode 100644 index 952544a25..000000000 --- a/numpy/core/SConscript +++ /dev/null @@ -1,531 +0,0 @@ -# Last Change: Sun Apr 26 05:00 PM 2009 J -# vim:syntax=python -import os -import sys -from os.path import join as pjoin, basename as pbasename, dirname as pdirname -from copy import deepcopy - -from numscons import get_pythonlib_dir -from numscons import GetNumpyEnvironment -from numscons import CheckCBLAS -from numscons import write_info - -from code_generators.numpy_api import \ - multiarray_api as multiarray_api_dict, \ - ufunc_api as ufunc_api_dict - -from setup_common import * -from scons_support import CheckBrokenMathlib, define_no_smp, \ - check_mlib, check_mlibs, is_npy_no_signal, CheckInline -from scons_support import array_api_gen_bld, ufunc_api_gen_bld, template_bld, \ - umath_bld, CheckGCC4, check_api_version, \ - CheckLongDoubleRepresentation - -import SCons - -# Set to True to enable multiple file compilations (experimental) -try: - os.environ['NPY_SEPARATE_COMPILATION'] - ENABLE_SEPARATE_COMPILATION = True -except KeyError: - ENABLE_SEPARATE_COMPILATION = False -try: - os.environ['NPY_BYPASS_SINGLE_EXTENDED'] - BYPASS_SINGLE_EXTENDED = True -except KeyError: - BYPASS_SINGLE_EXTENDED = False - -env = GetNumpyEnvironment(ARGUMENTS) -env.Append(CPPPATH = env["PYEXTCPPPATH"]) -if os.name == 'nt': - # NT needs the pythonlib to run any code importing Python.h, including - # simple code using only typedef and so on, so we need it for configuration - # checks - env.AppendUnique(LIBPATH = [get_pythonlib_dir()]) - -# Check whether we have a mismatch between the set C API VERSION and the -# actual C API VERSION -check_api_version(C_API_VERSION) - -#======================= -# Starting Configuration -#======================= -config = env.NumpyConfigure(custom_tests = {'CheckBrokenMathlib' : CheckBrokenMathlib, - 'CheckCBLAS' : CheckCBLAS, 'CheckInline': CheckInline, 'CheckGCC4' : CheckGCC4, - 'CheckLongDoubleRepresentation': CheckLongDoubleRepresentation}, - config_h = pjoin('config.h')) - -# numpyconfig_sym will keep the values of some configuration variables, the one -# needed for the public numpy API. - -# Convention: list of tuples (definition, value). value: -# - 0: #undef definition -# - 1: #define definition -# - string: #define definition value -numpyconfig_sym = [] - -#--------------- -# Checking Types -#--------------- -if not config.CheckHeader("Python.h"): - errmsg = [] - for line in config.GetLastError(): - errmsg.append("%s " % line) - print """ -Error: Python.h header cannot be compiled (or cannot be found). -On linux, check that you have python-dev/python-devel packages. On windows, -check that you have he platform SDK. You may also use unsupported cflags. -Configuration error log says: \n\n%s""" % ''.join(errmsg) - Exit(-1) - -st = config.CheckHeader("endian.h") -if st: - numpyconfig_sym.append(('DEFINE_NPY_HAVE_ENDIAN_H', '#define NPY_HAVE_ENDIAN_H 1')) -else: - numpyconfig_sym.append(('DEFINE_NPY_HAVE_ENDIAN_H', '')) - -def check_type(type, include = None): - st = config.CheckTypeSize(type, includes = include) - type = type.replace(' ', '_') - if st: - numpyconfig_sym.append(('SIZEOF_%s' % type.upper(), '%d' % st)) - else: - numpyconfig_sym.append(('SIZEOF_%s' % type.upper(), 0)) - -for type in ('short', 'int', 'long'): - # SIZEOF_LONG defined on darwin - if type == "long": - if not config.CheckDeclaration("SIZEOF_LONG", includes="#include <Python.h>"): - check_type(type) - else: - numpyconfig_sym.append(('SIZEOF_LONG', 'SIZEOF_LONG')) - else: - check_type(type) - -for type in ('float', 'double', 'long double'): - sz = config.CheckTypeSize(type) - numpyconfig_sym.append(('SIZEOF_%s' % type2def(type), str(sz))) - - # Compute size of corresponding complex type: used to check that our - # definition is binary compatible with C99 complex type (check done at - # build time in npy_common.h) - complex_def = "struct {%s __x; %s __y;}" % (type, type) - sz = config.CheckTypeSize(complex_def) - numpyconfig_sym.append(('SIZEOF_COMPLEX_%s' % type2def(type), str(sz))) - -if sys.platform != 'darwin': - tp = config.CheckLongDoubleRepresentation() - config.Define("HAVE_LDOUBLE_%s" % tp, 1, - "Define for arch-specific long double representation") - -for type in ('Py_intptr_t',): - check_type(type, include = "#include <Python.h>\n") - -# We check declaration AND type because that's how distutils does it. -if config.CheckDeclaration('PY_LONG_LONG', includes = '#include <Python.h>\n'): - st = config.CheckTypeSize('PY_LONG_LONG', - includes = '#include <Python.h>\n') - assert not st == 0 - numpyconfig_sym.append(('DEFINE_NPY_SIZEOF_LONGLONG', - '#define NPY_SIZEOF_LONGLONG %d' % st)) - numpyconfig_sym.append(('DEFINE_NPY_SIZEOF_PY_LONG_LONG', - '#define NPY_SIZEOF_PY_LONG_LONG %d' % st)) -else: - numpyconfig_sym.append(('DEFINE_NPY_SIZEOF_LONGLONG', '')) - numpyconfig_sym.append(('DEFINE_NPY_SIZEOF_PY_LONG_LONG', '')) - -if not config.CheckDeclaration('CHAR_BIT', includes= '#include <Python.h>\n'): - raise RuntimeError(\ -"""Config wo CHAR_BIT is not supported with scons: please contact the -maintainer (cdavid)""") - -#---------------------- -# Checking signal stuff -#---------------------- -if is_npy_no_signal(): - numpyconfig_sym.append(('DEFINE_NPY_NO_SIGNAL', '#define NPY_NO_SIGNAL\n')) - config.Define('__NPY_PRIVATE_NO_SIGNAL', - comment = "define to 1 to disable SMP support ") -else: - numpyconfig_sym.append(('DEFINE_NPY_NO_SIGNAL', '')) - -#--------------------- -# Checking SMP option -#--------------------- -if define_no_smp(): - nosmp = 1 -else: - nosmp = 0 -numpyconfig_sym.append(('NPY_NO_SMP', nosmp)) - -#---------------------------------------------- -# Check whether we can use C99 printing formats -#---------------------------------------------- -if config.CheckDeclaration(('PRIdPTR'), includes = '#include <inttypes.h>'): - numpyconfig_sym.append(('DEFINE_NPY_USE_C99_FORMATS', '#define NPY_USE_C99_FORMATS 1')) -else: - numpyconfig_sym.append(('DEFINE_NPY_USE_C99_FORMATS', '')) - -#---------------------- -# Checking the mathlib -#---------------------- -mlibs = [[], ['m'], ['cpml']] -mathlib = os.environ.get('MATHLIB') -if mathlib: - mlibs.insert(0, mathlib) - -mlib = check_mlibs(config, mlibs) - -# XXX: this is ugly: mathlib has nothing to do in a public header file -numpyconfig_sym.append(('MATHLIB', ','.join(mlib))) - -#---------------------------------- -# Checking the math funcs available -#---------------------------------- -# Function to check: -mfuncs = ('expl', 'expf', 'log1p', 'expm1', 'asinh', 'atanhf', 'atanhl', - 'rint', 'trunc') - -# Set value to 1 for each defined function (in math lib) -mfuncs_defined = dict([(f, 0) for f in mfuncs]) - -# Check for mandatory funcs: we barf if a single one of those is not there -if not config.CheckFuncsAtOnce(MANDATORY_FUNCS): - raise SystemError("One of the required function to build numpy is not" - " available (the list is %s)." % str(MANDATORY_FUNCS)) - -# Standard functions which may not be available and for which we have a -# replacement implementation -# -def check_funcs(funcs): - # Use check_funcs_once first, and if it does not work, test func per - # func. Return success only if all the functions are available - st = config.CheckFuncsAtOnce(funcs) - if not st: - # Global check failed, check func per func - for f in funcs: - st = config.CheckFunc(f, language = 'C') - -for f in OPTIONAL_STDFUNCS_MAYBE: - if config.CheckDeclaration(fname2def(f), - includes="#include <Python.h>\n#include <math.h>"): - OPTIONAL_STDFUNCS.remove(f) -check_funcs(OPTIONAL_STDFUNCS) - -# C99 functions: float and long double versions -if not BYPASS_SINGLE_EXTENDED: - check_funcs(C99_FUNCS_SINGLE) - check_funcs(C99_FUNCS_EXTENDED) - -# Normally, isnan and isinf are macro (C99), but some platforms only have -# func, or both func and macro version. Check for macro only, and define -# replacement ones if not found. -# Note: including Python.h is necessary because it modifies some math.h -# definitions -for f in ["isnan", "isinf", "signbit", "isfinite"]: - includes = """\ -#include <Python.h> -#include <math.h> -""" - st = config.CheckDeclaration(f, includes=includes) - if st: - numpyconfig_sym.append(('DEFINE_NPY_HAVE_DECL_%s' % f.upper(), - '#define NPY_HAVE_DECL_%s' % f.upper())) - else: - numpyconfig_sym.append(('DEFINE_NPY_HAVE_DECL_%s' % f.upper(), '')) - -inline = config.CheckInline() -config.Define('inline', inline) - - -if ENABLE_SEPARATE_COMPILATION: - config.Define("ENABLE_SEPARATE_COMPILATION", 1) - numpyconfig_sym.append(('DEFINE_NPY_ENABLE_SEPARATE_COMPILATION', '#define NPY_ENABLE_SEPARATE_COMPILATION 1')) -else: - numpyconfig_sym.append(('DEFINE_NPY_ENABLE_SEPARATE_COMPILATION', '')) - -#----------------------------- -# Checking for complex support -#----------------------------- -if config.CheckHeader('complex.h'): - numpyconfig_sym.append(('DEFINE_NPY_USE_C99_COMPLEX', '#define NPY_USE_C99_COMPLEX 1')) - - for t in C99_COMPLEX_TYPES: - st = config.CheckType(t, includes='#include <complex.h>') - if st: - numpyconfig_sym.append(('DEFINE_NPY_HAVE_%s' % type2def(t), - '#define NPY_HAVE_%s' % type2def(t))) - else: - numpyconfig_sym.append(('DEFINE_NPY_HAVE_%s' % type2def(t), '')) - - def check_prec(prec): - flist = [f + prec for f in C99_COMPLEX_FUNCS] - st = config.CheckFuncsAtOnce(flist) - if not st: - # Global check failed, check func per func - for f in flist: - config.CheckFunc(f, language='C') - - check_prec('') - check_prec('f') - check_prec('l') - -else: - numpyconfig_sym.append(('DEFINE_NPY_USE_C99_COMPLEX', '')) - for t in C99_COMPLEX_TYPES: - numpyconfig_sym.append(('DEFINE_NPY_HAVE_%s' % type2def(t), '')) - -def visibility_define(): - if config.CheckGCC4(): - return '__attribute__((visibility("hidden")))' - else: - return '' - -numpyconfig_sym.append(('VISIBILITY_HIDDEN', visibility_define())) - -# Add the C API/ABI versions -numpyconfig_sym.append(('NPY_ABI_VERSION', '0x%.8X' % C_ABI_VERSION)) -numpyconfig_sym.append(('NPY_API_VERSION', '0x%.8X' % C_API_VERSION)) - -# Check whether we need our own wide character support -if not config.CheckDeclaration('Py_UNICODE_WIDE', includes='#include <Python.h>'): - PYTHON_HAS_UNICODE_WIDE = True -else: - PYTHON_HAS_UNICODE_WIDE = False - -#------------------------------------------------------- -# Define the function PyOS_ascii_strod if not available -#------------------------------------------------------- -if not config.CheckDeclaration('PyOS_ascii_strtod', - includes = "#include <Python.h>"): - if config.CheckFunc('strtod'): - config.Define('PyOS_ascii_strtod', 'strtod', - "Define to a function to use as a replacement for "\ - "PyOS_ascii_strtod if not available in python header") - -#------------------------------------ -# DISTUTILS Hack on AMD64 on windows -#------------------------------------ -# XXX: this is ugly -if sys.platform=='win32' or os.name=='nt': - from distutils.msvccompiler import get_build_architecture - a = get_build_architecture() - print 'BUILD_ARCHITECTURE: %r, os.name=%r, sys.platform=%r' % \ - (a, os.name, sys.platform) - if a == 'AMD64': - distutils_use_sdk = 1 - config.Define('DISTUTILS_USE_SDK', distutils_use_sdk, - "define to 1 to disable SMP support ") - - if a == "Intel": - config.Define('FORCE_NO_LONG_DOUBLE_FORMATTING', 1, - "define to 1 to force long double format string to the" \ - " same as double (Lg -> g)") -#-------------- -# Checking Blas -#-------------- -if config.CheckCBLAS(): - build_blasdot = 1 -else: - build_blasdot = 0 - -config.config_h_text += """ -#ifndef _NPY_NPY_CONFIG_H_ -#error config.h should never be included directly, include npy_config.h instead -#endif -""" - -config.Finish() -write_info(env) - -#========== -# Build -#========== - -# List of headers which need to be "installed " into the build directory for -# proper in-place build support -generated_headers = [] - -#--------------------------------------- -# Generate the public configuration file -#--------------------------------------- -config_dict = {} -# XXX: this is ugly, make the API for config.h and numpyconfig.h similar -for key, value in numpyconfig_sym: - config_dict['@%s@' % key] = str(value) -env['SUBST_DICT'] = config_dict - -include_dir = 'include/numpy' -target = env.SubstInFile(pjoin(include_dir, '_numpyconfig.h'), - pjoin(include_dir, '_numpyconfig.h.in')) -generated_headers.append(target[0]) - -env['CONFIG_H_GEN'] = numpyconfig_sym - -#--------------------------- -# Builder for generated code -#--------------------------- -env.Append(BUILDERS = {'GenerateMultiarrayApi' : array_api_gen_bld, - 'GenerateUfuncApi' : ufunc_api_gen_bld, - 'GenerateFromTemplate' : template_bld, - 'GenerateUmath' : umath_bld}) - -#------------------------ -# Generate generated code -#------------------------ -scalartypes_src = env.GenerateFromTemplate( - pjoin('src', 'multiarray', 'scalartypes.c.src')) -umath_funcs_src = env.GenerateFromTemplate(pjoin('src', 'umath', 'funcs.inc.src')) -umath_loops_src = env.GenerateFromTemplate(pjoin('src', 'umath', 'loops.c.src')) -arraytypes_src = env.GenerateFromTemplate( - pjoin('src', 'multiarray', 'arraytypes.c.src')) -nditer_src = env.GenerateFromTemplate( - pjoin('src', 'multiarray', 'nditer_templ.c.src')) -lowlevel_strided_loops_src = env.GenerateFromTemplate( - pjoin('src', 'multiarray', 'lowlevel_strided_loops.c.src')) -einsum_src = env.GenerateFromTemplate(pjoin('src', 'multiarray', 'einsum.c.src')) -umath_tests_src = env.GenerateFromTemplate(pjoin('src', 'umath', - 'umath_tests.c.src')) -multiarray_tests_src = env.GenerateFromTemplate(pjoin('src', 'multiarray', - 'multiarray_tests.c.src')) -scalarmathmodule_src = env.GenerateFromTemplate( - pjoin('src', 'scalarmathmodule.c.src')) - -umath = env.GenerateUmath('__umath_generated', - pjoin('code_generators', 'generate_umath.py')) - -multiarray_api = env.GenerateMultiarrayApi('include/numpy/multiarray_api', - [SCons.Node.Python.Value(d) for d in multiarray_api_dict]) -generated_headers.append(multiarray_api[0]) - -ufunc_api = env.GenerateUfuncApi('include/numpy/ufunc_api', - [SCons.Node.Python.Value(d) for d in ufunc_api_dict]) -generated_headers.append(ufunc_api[0]) - -# include/numpy is added for compatibility reasons with distutils: this is -# needed for __multiarray_api.c and __ufunc_api.c included from multiarray and -# ufunc. -env.Prepend(CPPPATH = ['src/private', 'include', '.', 'include/numpy']) - -# npymath core lib -npymath_src = [env.GenerateFromTemplate(pjoin('src', 'npymath', 'npy_math.c.src')), - env.GenerateFromTemplate(pjoin('src', 'npymath', 'npy_math_complex.c.src')), - env.GenerateFromTemplate(pjoin('src', 'npymath', 'ieee754.c.src')), - pjoin('src', 'npymath', 'halffloat.c')] -env.DistutilsInstalledStaticExtLibrary("npymath", npymath_src, install_dir='lib') -env.Prepend(LIBS=["npymath"]) -env.Prepend(LIBPATH=["."]) - -subst_dict = {'@prefix@': '$distutils_install_prefix', - '@pkgname@': 'numpy.core', '@sep@': os.path.sep} -npymath_ini = env.SubstInFile(pjoin('lib', 'npy-pkg-config', 'npymath.ini'), - 'npymath.ini.in', SUBST_DICT=subst_dict) - -subst_dict = {'@posix_mathlib@': " ".join(['-l%s' % l for l in mlib]), - '@msvc_mathlib@': " ".join(['%s.mlib' % l for l in mlib])} -mlib_ini = env.SubstInFile(pjoin('lib', 'npy-pkg-config', 'mlib.ini'), - 'mlib.ini.in', SUBST_DICT=subst_dict) -env.Install('$distutils_installdir/lib/npy-pkg-config', mlib_ini) -env.Install('$distutils_installdir/lib/npy-pkg-config', npymath_ini) - -# npysort core lib -npysort_src = [env.GenerateFromTemplate(pjoin('src', 'npysort', 'quicksort.c.src')), - env.GenerateFromTemplate(pjoin('src', 'npysort', 'mergesort.c.src')), - env.GenerateFromTemplate(pjoin('src', 'npysort', 'heapsort.c.src'))] -env.StaticExtLibrary("npysort", npysort_src) -env.Prepend(LIBS=["npysort"]) -env.Prepend(LIBPATH=["."]) - -#----------------- -# Build multiarray -#----------------- -if ENABLE_SEPARATE_COMPILATION: - multiarray_src = [pjoin('src', 'multiarray', 'multiarraymodule.c'), - pjoin('src', 'multiarray', 'hashdescr.c'), - pjoin('src', 'multiarray', 'arrayobject.c'), - pjoin('src', 'multiarray', 'array_assign.c'), - pjoin('src', 'multiarray', 'array_assign_scalar.c'), - pjoin('src', 'multiarray', 'array_assign_array.c'), - pjoin('src', 'multiarray', 'datetime.c'), - pjoin('src', 'multiarray', 'datetime_strings.c'), - pjoin('src', 'multiarray', 'datetime_busday.c'), - pjoin('src', 'multiarray', 'datetime_busdaycal.c'), - pjoin('src', 'multiarray', 'numpyos.c'), - pjoin('src', 'multiarray', 'flagsobject.c'), - pjoin('src', 'multiarray', 'descriptor.c'), - pjoin('src', 'multiarray', 'iterators.c'), - pjoin('src', 'multiarray', 'mapping.c'), - pjoin('src', 'multiarray', 'number.c'), - pjoin('src', 'multiarray', 'getset.c'), - pjoin('src', 'multiarray', 'sequence.c'), - pjoin('src', 'multiarray', 'methods.c'), - pjoin('src', 'multiarray', 'ctors.c'), - pjoin('src', 'multiarray', 'convert_datatype.c'), - pjoin('src', 'multiarray', 'convert.c'), - pjoin('src', 'multiarray', 'shape.c'), - pjoin('src', 'multiarray', 'item_selection.c'), - pjoin('src', 'multiarray', 'calculation.c'), - pjoin('src', 'multiarray', 'common.c'), - pjoin('src', 'multiarray', 'refcount.c'), - pjoin('src', 'multiarray', 'conversion_utils.c'), - pjoin('src', 'multiarray', 'usertypes.c'), - pjoin('src', 'multiarray', 'buffer.c'), - pjoin('src', 'multiarray', 'numpymemoryview.c'), - pjoin('src', 'multiarray', 'scalarapi.c'), - pjoin('src', 'multiarray', 'nditer_api.c'), - pjoin('src', 'multiarray', 'nditer_constr.c'), - pjoin('src', 'multiarray', 'nditer_pywrap.c'), - pjoin('src', 'multiarray', 'dtype_transfer.c'), - pjoin("src", "multiarray", "ucsnarrow.c")] - multiarray_src.extend(arraytypes_src) - multiarray_src.extend(scalartypes_src) - multiarray_src.extend(lowlevel_strided_loops_src) - multiarray_src.extend(nditer_src) - multiarray_src.extend(einsum_src) -else: - multiarray_src = [pjoin('src', 'multiarray', 'multiarraymodule_onefile.c')] -multiarray = env.DistutilsPythonExtension('multiarray', source = multiarray_src) -env.DistutilsPythonExtension('multiarray_tests', source=multiarray_tests_src) - -#------------------- -# Build umath module -#------------------- -if ENABLE_SEPARATE_COMPILATION: - umathmodule_src.extend([pjoin('src', 'umath', 'ufunc_object.c')]) - umathmodule_src.extend([pjoin('src', 'umath', 'ufunc_type_resolution.c')]) - umathmodule_src.extend([pjoin('src', 'multiarray', 'reduction.c')]), - umathmodule_src.extend(umath_loops_src) -else: - umathmodule_src = [pjoin('src', 'umath', 'umathmodule_onefile.c')] -umathmodule = env.DistutilsPythonExtension('umath', source = umathmodule_src) - -#------------------------ -# Build scalarmath module -#------------------------ -scalarmathmodule = env.DistutilsPythonExtension('scalarmath', - source = scalarmathmodule_src) - -#------------------------ -# Build scalarmath module -#------------------------ -umath_tests = env.DistutilsPythonExtension('umath_tests', - source=umath_tests_src) - -#---------------------- -# Build _dotblas module -#---------------------- -if build_blasdot: - dotblas_src = [pjoin('blasdot', i) for i in ['_dotblas.c']] - # because _dotblas does #include CBLAS_HEADER instead of #include - # "cblas.h", scons does not detect the dependency - # XXX: PythonExtension builder does not take the Depends on extension into - # account for some reason, so we first build the object, with forced - # dependency, and then builds the extension. This is more likely a bug in - # our PythonExtension builder, but I cannot see how to solve it. - dotblas_o = env.PythonObject('_dotblas', source = dotblas_src) - env.Depends(dotblas_o, pjoin("blasdot", "cblas.h")) - dotblas = env.DistutilsPythonExtension('_dotblas', dotblas_o) - -# "Install" the header in the build directory, so that in-place build works -for h in generated_headers: - env.Install(pjoin('$distutils_installdir', include_dir), h) diff --git a/numpy/core/SConstruct b/numpy/core/SConstruct deleted file mode 100644 index a377d8391..000000000 --- a/numpy/core/SConstruct +++ /dev/null @@ -1,2 +0,0 @@ -from numscons import GetInitEnvironment -GetInitEnvironment(ARGUMENTS).DistutilsSConscript('SConscript') diff --git a/numpy/core/scons_support.py b/numpy/core/scons_support.py deleted file mode 100644 index 048f85db6..000000000 --- a/numpy/core/scons_support.py +++ /dev/null @@ -1,272 +0,0 @@ -#! Last Change: Sun Apr 26 05:00 PM 2009 J - -"""Code to support special facilities to scons which are only useful for -numpy.core, hence not put into numpy.distutils.scons""" - -import sys -import os - -from os.path import join as pjoin, dirname as pdirname, basename as pbasename -from copy import deepcopy - -import code_generators -from code_generators.generate_numpy_api import \ - do_generate_api as nowrap_do_generate_numpy_api -from code_generators.generate_ufunc_api import \ - do_generate_api as nowrap_do_generate_ufunc_api -from setup_common import check_api_version as _check_api_version -from setup_common import \ - LONG_DOUBLE_REPRESENTATION_SRC, pyod, long_double_representation - -from numscons.numdist import process_c_str as process_str - -import SCons.Node -import SCons -from SCons.Builder import Builder -from SCons.Action import Action - -def check_api_version(apiversion): - return _check_api_version(apiversion, pdirname(code_generators.__file__)) - -def split_ext(string): - sp = string.rsplit( '.', 1) - if len(sp) == 1: - return (sp[0], '') - else: - return sp -#------------------------------------ -# Ufunc and multiarray API generators -#------------------------------------ -def do_generate_numpy_api(target, source, env): - nowrap_do_generate_numpy_api([str(i) for i in target], - [s.value for s in source]) - return 0 - -def do_generate_ufunc_api(target, source, env): - nowrap_do_generate_ufunc_api([str(i) for i in target], - [s.value for s in source]) - return 0 - -def generate_api_emitter(target, source, env): - """Returns the list of targets generated by the code generator for array - api and ufunc api.""" - base, ext = split_ext(str(target[0])) - dir = pdirname(base) - ba = pbasename(base) - h = pjoin(dir, '__' + ba + '.h') - c = pjoin(dir, '__' + ba + '.c') - txt = base + '.txt' - #print h, c, txt - t = [h, c, txt] - return (t, source) - -#------------------------- -# From template generators -#------------------------- -# XXX: this is general and can be used outside numpy.core. -def do_generate_from_template(targetfile, sourcefile, env): - t = open(targetfile, 'w') - s = open(sourcefile, 'r') - allstr = s.read() - s.close() - writestr = process_str(allstr) - t.write(writestr) - t.close() - return 0 - -def generate_from_template(target, source, env): - for t, s in zip(target, source): - do_generate_from_template(str(t), str(s), env) - -def generate_from_template_emitter(target, source, env): - base, ext = split_ext(pbasename(str(source[0]))) - t = pjoin(pdirname(str(target[0])), base) - return ([t], source) - -#---------------- -# umath generator -#---------------- -def do_generate_umath(targetfile, sourcefile, env): - t = open(targetfile, 'w') - from code_generators import generate_umath - code = generate_umath.make_code(generate_umath.defdict, generate_umath.__file__) - t.write(code) - t.close() - -def generate_umath(target, source, env): - for t, s in zip(target, source): - do_generate_umath(str(t), str(s), env) - -def generate_umath_emitter(target, source, env): - t = str(target[0]) + '.c' - return ([t], source) - -#----------------------------------------- -# Other functions related to configuration -#----------------------------------------- -def CheckGCC4(context): - src = """ -int -main() -{ -#if !(defined __GNUC__ && (__GNUC__ >= 4)) -die from an horrible death -#endif -} -""" - - context.Message("Checking if compiled with gcc 4.x or above ... ") - st = context.TryCompile(src, '.c') - - if st: - context.Result(' yes') - else: - context.Result(' no') - return st == 1 - -def CheckBrokenMathlib(context, mathlib): - src = """ -/* check whether libm is broken */ -#include <math.h> -int main(int argc, char *argv[]) -{ - return exp(-720.) > 1.0; /* typically an IEEE denormal */ -} -""" - - try: - oldLIBS = deepcopy(context.env['LIBS']) - except: - oldLIBS = [] - - try: - context.Message("Checking if math lib %s is usable for numpy ... " % mathlib) - context.env.AppendUnique(LIBS = mathlib) - st = context.TryRun(src, '.c') - finally: - context.env['LIBS'] = oldLIBS - - if st[0]: - context.Result(' Yes !') - else: - context.Result(' No !') - return st[0] - -def check_mlib(config, mlib): - """Return 1 if mlib is available and usable by numpy, 0 otherwise. - - mlib can be a string (one library), or a list of libraries.""" - # Check the libraries in mlib are linkable - if len(mlib) > 0: - # XXX: put an autoadd argument to 0 here and add an autoadd argument to - # CheckBroekenMathlib (otherwise we may add bogus libraries, the ones - # which do not path the CheckBrokenMathlib test). - st = config.CheckLib(mlib) - if not st: - return 0 - # Check the mlib is usable by numpy - return config.CheckBrokenMathlib(mlib) - -def check_mlibs(config, mlibs): - for mlib in mlibs: - if check_mlib(config, mlib): - return mlib - - # No mlib was found. - raise SCons.Errors.UserError("No usable mathlib was found: chose another "\ - "one using the MATHLIB env variable, eg "\ - "'MATHLIB=m python setup.py build'") - - -def is_npy_no_signal(): - """Return True if the NPY_NO_SIGNAL symbol must be defined in configuration - header.""" - return sys.platform == 'win32' - -def define_no_smp(): - """Returns True if we should define NPY_NOSMP, False otherwise.""" - #-------------------------------- - # Checking SMP and thread options - #-------------------------------- - # Python 2.3 causes a segfault when - # trying to re-acquire the thread-state - # which is done in error-handling - # ufunc code. NPY_ALLOW_C_API and friends - # cause the segfault. So, we disable threading - # for now. - if sys.version[:5] < '2.4.2': - nosmp = 1 - else: - # Perhaps a fancier check is in order here. - # so that threads are only enabled if there - # are actually multiple CPUS? -- but - # threaded code can be nice even on a single - # CPU so that long-calculating code doesn't - # block. - try: - nosmp = os.environ['NPY_NOSMP'] - nosmp = 1 - except KeyError: - nosmp = 0 - return nosmp == 1 - -# Inline check -def CheckInline(context): - context.Message("Checking for inline keyword... ") - body = """ -#ifndef __cplusplus -static %(inline)s int static_func (void) -{ - return 0; -} -%(inline)s int nostatic_func (void) -{ - return 0; -} -#endif""" - inline = None - for kw in ['inline', '__inline__', '__inline']: - st = context.TryCompile(body % {'inline': kw}, '.c') - if st: - inline = kw - break - - if inline: - context.Result(inline) - else: - context.Result(0) - return inline - -def CheckLongDoubleRepresentation(context): - msg = { - 'INTEL_EXTENDED_12_BYTES_LE': "Intel extended, little endian", - 'INTEL_EXTENDED_16_BYTES_LE': "Intel extended, little endian", - 'IEEE_QUAD_BE': "IEEE Quad precision, big endian", - 'IEEE_QUAD_LE': "IEEE Quad precision, little endian", - 'IEEE_DOUBLE_LE': "IEEE Double precision, little endian", - 'IEEE_DOUBLE_BE': "IEEE Double precision, big endian" - } - - context.Message("Checking for long double representation... ") - body = LONG_DOUBLE_REPRESENTATION_SRC % {'type': 'long double'} - st = context.TryCompile(body, '.c') - if st: - obj = str(context.sconf.lastTarget) - tp = long_double_representation(pyod(obj)) - context.Result(msg[tp]) - return tp - if not st: - context.Result(0) - -array_api_gen_bld = Builder(action = Action(do_generate_numpy_api, '$ARRAYPIGENCOMSTR'), - emitter = generate_api_emitter) - - -ufunc_api_gen_bld = Builder(action = Action(do_generate_ufunc_api, '$UFUNCAPIGENCOMSTR'), - emitter = generate_api_emitter) - -template_bld = Builder(action = Action(generate_from_template, '$TEMPLATECOMSTR'), - emitter = generate_from_template_emitter) - -umath_bld = Builder(action = Action(generate_umath, '$UMATHCOMSTR'), - emitter = generate_umath_emitter) diff --git a/numpy/core/setup_common.py b/numpy/core/setup_common.py index 83589695d..1674333ca 100644 --- a/numpy/core/setup_common.py +++ b/numpy/core/setup_common.py @@ -1,4 +1,4 @@ -# Code shared by distutils and scons builds +# Code common to build tools import sys from os.path import join import warnings diff --git a/numpy/core/setupscons.py b/numpy/core/setupscons.py deleted file mode 100644 index 4d329fded..000000000 --- a/numpy/core/setupscons.py +++ /dev/null @@ -1,111 +0,0 @@ -import os -import sys -import glob -from os.path import join, basename - -from numpy.distutils import log - -from numscons import get_scons_build_dir - -def configuration(parent_package='',top_path=None): - from numpy.distutils.misc_util import Configuration,dot_join - from numpy.distutils.command.scons import get_scons_pkg_build_dir - from numpy.distutils.system_info import get_info, default_lib_dirs - - config = Configuration('core',parent_package,top_path) - local_dir = config.local_path - - header_dir = 'include/numpy' # this is relative to config.path_in_package - - config.add_subpackage('code_generators') - - # List of files to register to numpy.distutils - dot_blas_src = [join('blasdot', '_dotblas.c'), - join('blasdot', 'cblas.h')] - api_definition = [join('code_generators', 'numpy_api_order.txt'), - join('code_generators', 'ufunc_api_order.txt')] - core_src = [join('src', basename(i)) for i in glob.glob(join(local_dir, - 'src', - '*.c'))] - core_src += [join('src', basename(i)) for i in glob.glob(join(local_dir, - 'src', - '*.src'))] - - source_files = dot_blas_src + api_definition + core_src + \ - [join(header_dir, 'numpyconfig.h.in')] - - # Add generated files to distutils... - def add_config_header(): - scons_build_dir = get_scons_build_dir() - # XXX: I really have to think about how to communicate path info - # between scons and distutils, and set the options at one single - # location. - target = join(get_scons_pkg_build_dir(config.name), 'config.h') - incl_dir = os.path.dirname(target) - if incl_dir not in config.numpy_include_dirs: - config.numpy_include_dirs.append(incl_dir) - - def add_numpyconfig_header(): - scons_build_dir = get_scons_build_dir() - # XXX: I really have to think about how to communicate path info - # between scons and distutils, and set the options at one single - # location. - target = join(get_scons_pkg_build_dir(config.name), - 'include/numpy/numpyconfig.h') - incl_dir = os.path.dirname(target) - if incl_dir not in config.numpy_include_dirs: - config.numpy_include_dirs.append(incl_dir) - config.add_data_files((header_dir, target)) - - def add_array_api(): - scons_build_dir = get_scons_build_dir() - # XXX: I really have to think about how to communicate path info - # between scons and distutils, and set the options at one single - # location. - h_file = join(get_scons_pkg_build_dir(config.name), - 'include/numpy/__multiarray_api.h') - t_file = join(get_scons_pkg_build_dir(config.name), - 'include/numpy/multiarray_api.txt') - config.add_data_files((header_dir, h_file), - (header_dir, t_file)) - - def add_ufunc_api(): - scons_build_dir = get_scons_build_dir() - # XXX: I really have to think about how to communicate path info - # between scons and distutils, and set the options at one single - # location. - h_file = join(get_scons_pkg_build_dir(config.name), - 'include/numpy/__ufunc_api.h') - t_file = join(get_scons_pkg_build_dir(config.name), - 'include/numpy/ufunc_api.txt') - config.add_data_files((header_dir, h_file), - (header_dir, t_file)) - - def add_generated_files(*args, **kw): - add_config_header() - add_numpyconfig_header() - add_array_api() - add_ufunc_api() - - config.add_sconscript('SConstruct', - post_hook = add_generated_files, - source_files = source_files) - config.add_scons_installed_library('npymath', 'lib') - - config.add_data_files('include/numpy/*.h') - config.add_include_dirs('src') - - config.numpy_include_dirs.extend(config.paths('include')) - - # Don't install fenv unless we need them. - if sys.platform == 'cygwin': - config.add_data_dir('include/numpy/fenv') - - config.add_data_dir('tests') - config.make_svn_version_py() - - return config - -if __name__=='__main__': - from numpy.distutils.core import setup - setup(configuration=configuration) |
