Skip to content

Commit

Permalink
BUG: (#1221) special case mac os x in numpyconfig.h
Browse files Browse the repository at this point in the history
Universal builds break the configure stage: we have to harcode the
arch-specific values in the case of mac os x, as we have only one configuration
stage per compile, but several arch per compile with the braindead -arch
machinery.

We rename the old numpyconfig.h to a private header, and numpyconfig.h itself
post-fix the values in the case of mac os x.

(cherry picked from commit 60e90d68441f40e45b0e38bda396b8056bf31fc5)
  • Loading branch information
cournape committed Nov 27, 2009
1 parent 8ad949b commit 65880fd
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
4 changes: 2 additions & 2 deletions numpy/core/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ for key, value in numpyconfig_sym:
env['SUBST_DICT'] = config_dict

include_dir = 'include/numpy'
target = env.SubstInFile(pjoin(include_dir, 'numpyconfig.h'),
pjoin(include_dir, 'numpyconfig.h.in'))
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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifndef _NPY_NUMPYCONFIG_H_
#error this header should not be included directly, always include numpyconfig.h instead
#endif

#define NPY_SIZEOF_SHORT @SIZEOF_SHORT@
#define NPY_SIZEOF_INT @SIZEOF_INT@
#define NPY_SIZEOF_LONG @SIZEOF_LONG@
Expand Down
24 changes: 24 additions & 0 deletions numpy/core/include/numpy/numpyconfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef _NPY_NUMPYCONFIG_H_
#define _NPY_NUMPYCONFIG_H_

#include "_numpyconfig.h"

/*
* On Mac OS X, because there is only one configuration stage for all the archs
* in universal builds, any macro which depends on the arch needs to be
* harcoded
*/
#ifdef __APPLE__
#undef NPY_SIZEOF_LONG
#undef NPY_SIZEOF_PY_INTPTR_T

#ifdef __LP64__
#define NPY_SIZEOF_LONG 8
#define NPY_SIZEOF_PY_INTPTR_T 8
#else
#define NPY_SIZEOF_LONG 4
#define NPY_SIZEOF_PY_INTPTR_T 4
#endif
#endif

#endif
2 changes: 1 addition & 1 deletion numpy/core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def generate_config_h(ext, build_dir):

def generate_numpyconfig_h(ext, build_dir):
"""Depends on config.h: generate_config_h has to be called before !"""
target = join(build_dir,header_dir,'numpyconfig.h')
target = join(build_dir,header_dir,'_numpyconfig.h')
d = os.path.dirname(target)
if not os.path.exists(d):
os.makedirs(d)
Expand Down
6 changes: 3 additions & 3 deletions numpy/distutils/misc_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,17 @@ def get_mathlibs(path=None):
"""Return the MATHLIB line from numpyconfig.h
"""
if path is not None:
config_file = os.path.join(path,'numpyconfig.h')
config_file = os.path.join(path,'_numpyconfig.h')
else:
# Look for the file in each of the numpy include directories.
dirs = get_numpy_include_dirs()
for path in dirs:
fn = os.path.join(path,'numpyconfig.h')
fn = os.path.join(path,'_numpyconfig.h')
if os.path.exists(fn):
config_file = fn
break
else:
raise DistutilsError('numpyconfig.h not found in numpy include '
raise DistutilsError('_numpyconfig.h not found in numpy include '
'dirs %r' % (dirs,))

fid = open(config_file)
Expand Down

0 comments on commit 65880fd

Please sign in to comment.