diff options
author | David Cournapeau <cournape@gmail.com> | 2008-11-17 13:58:23 +0000 |
---|---|---|
committer | David Cournapeau <cournape@gmail.com> | 2008-11-17 13:58:23 +0000 |
commit | 5a722a6ef88bc75d2907f01674e1370a31b92cd2 (patch) | |
tree | 8ab049e4c196a3a75bc5001b589800cbdb03db35 | |
parent | 85887fb88a96821340c11d0a976bb95221f0174c (diff) | |
parent | c964b6ad6475445e0f78a91a05e6de2d81305168 (diff) | |
download | numpy-5a722a6ef88bc75d2907f01674e1370a31b92cd2.tar.gz |
Merged revisions 6071-6076 via svnmerge from
http://svn.scipy.org/svn/numpy/trunk
........
r6072 | cdavid | 2008-11-17 22:52:47 +0900 (Mon, 17 Nov 2008) | 1 line
Fix the inaccurate comment regarding _ftime issues with mingw.
........
r6073 | cdavid | 2008-11-17 22:53:05 +0900 (Mon, 17 Nov 2008) | 1 line
Do not generate a config.h for randomkit: it does not work as it is, and adding per-subpackage include path is a PITA with distutils.
........
r6074 | cdavid | 2008-11-17 22:53:25 +0900 (Mon, 17 Nov 2008) | 1 line
Conditionally setup mingw workaround on __GNUC__ since we can't detect if we are built with mingw in distutils setup.py.
........
r6075 | cdavid | 2008-11-17 22:53:42 +0900 (Mon, 17 Nov 2008) | 1 line
Forgot to update needs_mingw_ftime_workaround function.
........
r6076 | cdavid | 2008-11-17 22:53:58 +0900 (Mon, 17 Nov 2008) | 1 line
Include time.h and sys/timeb.h just after defining our custom __MSVCRT_VERSION__ to avoid possible duplicate.
........
-rw-r--r-- | numpy/random/mtrand/randomkit.c | 14 | ||||
-rw-r--r-- | numpy/random/setup.py | 39 |
2 files changed, 20 insertions, 33 deletions
diff --git a/numpy/random/mtrand/randomkit.c b/numpy/random/mtrand/randomkit.c index c13e59f7a..b54b0e778 100644 --- a/numpy/random/mtrand/randomkit.c +++ b/numpy/random/mtrand/randomkit.c @@ -64,8 +64,6 @@ /* static char const rcsid[] = "@(#) $Jeannot: randomkit.c,v 1.28 2005/07/21 22:14:09 js Exp $"; */ -#include "config.h" - #include <stddef.h> #include <stdio.h> #include <stdlib.h> @@ -75,20 +73,22 @@ #ifdef _WIN32 /* Windows */ -#ifdef NPY_NEEDS_MINGW_TIME_WORKAROUND +/* XXX: we have to use this ugly defined(__GNUC__) because it is not easy to + * detect the compiler used in distutils itself */ +#if (defined(__GNUC__) && defined(NPY_NEEDS_MINGW_TIME_WORKAROUND)) /* FIXME: ideally, we should set this to the real version of MSVCRT. We need * something higher than 0x601 to enable _ftime64 and co */ #define __MSVCRT_VERSION__ 0x0700 +#include <time.h> +#include <sys/timeb.h> /* mingw msvcr lib import wrongly export _ftime, which does not exist in the - * actual msvc runtime for version >= 8; we make it an alist to _ftime64, which - * is available in those versions of the runtime and should be ABI compatible + * actual msvc runtime for version >= 8; we make it an alias to _ftime64, which + * is available in those versions of the runtime */ #define _FTIME(x) _ftime64((x)) #else #define _FTIME(x) _ftime((x)) #endif -#include <time.h> -#include <sys/timeb.h> #ifndef RK_NO_WINCRYPT /* Windows crypto */ #ifndef _WIN32_WINNT diff --git a/numpy/random/setup.py b/numpy/random/setup.py index d1d867acf..c8b0a5cf5 100644 --- a/numpy/random/setup.py +++ b/numpy/random/setup.py @@ -4,13 +4,14 @@ import sys from distutils.dep_util import newer from distutils.msvccompiler import get_build_version as get_msvc_build_version -def needs_mingw_ftime_workaround(config): +def needs_mingw_ftime_workaround(): # We need the mingw workaround for _ftime if the msvc runtime version is - # 7.1 or above and we build with mingw - if config.compiler.compiler_type == 'mingw32': - msver = get_msvc_build_version() - if msver and msver > 7: - return True + # 7.1 or above and we build with mingw ... + # ... but we can't easily detect compiler version outside distutils command + # context, so we will need to detect in randomkit whether we build with gcc + msver = get_msvc_build_version() + if msver and msver > 7: + return True return False @@ -27,36 +28,22 @@ def configuration(parent_package='',top_path=None): ext.libraries.extend(libs) return None - def generate_config_h(ext, build_dir): - defs = [] - target = join(build_dir, "mtrand", 'config.h') - dir = dirname(target) - if not os.path.exists(dir): - os.makedirs(dir) - - config_cmd = config.get_config_cmd() - if needs_mingw_ftime_workaround(config_cmd): - defs.append("NPY_NEEDS_MINGW_TIME_WORKAROUND") - - if newer(__file__, target): - target_f = open(target, 'a') - for d in defs: - if isinstance(d, str): - target_f.write('#define %s\n' % (d)) - target_f.close() + defs = [] + if needs_mingw_ftime_workaround(): + defs.append(("NPY_NEEDS_MINGW_TIME_WORKAROUND", None)) libs = [] # Configure mtrand config.add_extension('mtrand', sources=[join('mtrand', x) for x in ['mtrand.c', 'randomkit.c', 'initarray.c', - 'distributions.c']]+[generate_libraries] - + [generate_config_h], + 'distributions.c']]+[generate_libraries], libraries=libs, depends = [join('mtrand','*.h'), join('mtrand','*.pyx'), join('mtrand','*.pxi'), - ] + ], + define_macros = defs, ) config.add_data_files(('.', join('mtrand', 'randomkit.h'))) |