Skip to content

Commit

Permalink
Generate headers in the right place for inplace builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
rkern committed Jul 19, 2008
1 parent f3bef65 commit c003f55
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
17 changes: 13 additions & 4 deletions numpy/core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ def configuration(parent_package='',top_path=None):
header_dir = 'include/numpy' # this is relative to config.path_in_package

def generate_config_h(ext, build_dir):
target = join(build_dir,'config.h')
target = join(build_dir,header_dir,'config.h')
dir = os.path.dirname(target)
if not os.path.exists(dir):
os.makedirs(dir)
if newer(__file__,target):
config_cmd = config.get_config_cmd()
log.info('Generating %s',target)
Expand Down Expand Up @@ -159,7 +162,10 @@ def check_func(func_name):

def generate_numpyconfig_h(ext, build_dir):
"""Depends on config.h: generate_config_h has to be called before !"""
target = join(build_dir,'numpyconfig.h')
target = join(build_dir,header_dir,'numpyconfig.h')
dir = os.path.dirname(target)
if not os.path.exists(dir):
os.makedirs(dir)
if newer(__file__,target):
config_cmd = config.get_config_cmd()
log.info('Generating %s',target)
Expand Down Expand Up @@ -198,7 +204,7 @@ def generate_api(ext, build_dir):
try:
m = __import__(module_name)
log.info('executing %s', script)
h_file, c_file, doc_file = m.generate_api(build_dir)
h_file, c_file, doc_file = m.generate_api(os.path.join(build_dir, header_dir))
finally:
del sys.path[0]
config.add_data_files((header_dir, h_file),
Expand All @@ -210,7 +216,10 @@ def generate_api(ext, build_dir):
generate_ufunc_api = generate_api_func('generate_ufunc_api')

def generate_umath_c(ext,build_dir):
target = join(build_dir,'__umath_generated.c')
target = join(build_dir,header_dir,'__umath_generated.c')
dir = os.path.dirname(target)
if not os.path.exists(dir):
os.makedirs(dir)
script = generate_umath_py
if newer(script,target):
f = open(target,'w')
Expand Down
17 changes: 14 additions & 3 deletions numpy/distutils/misc_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,20 @@ def njoin(*path):
def get_mathlibs(path=None):
"""Return the MATHLIB line from numpyconfig.h
"""
if path is None:
path = os.path.join(get_numpy_include_dirs()[0], 'numpy')
config_file = os.path.join(path,'numpyconfig.h')
if path is not None:
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')
if os.path.exists(fn):
config_file = fn
break
else:
raise DistutilsError('numpyconfig.h not found in numpy include '
'dirs %r' % (dirs,))

fid = open(config_file)
mathlibs = []
s = '#define MATHLIB'
Expand Down
6 changes: 1 addition & 5 deletions numpy/random/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ def configuration(parent_package='',top_path=None):

def generate_libraries(ext, build_dir):
config_cmd = config.get_config_cmd()
if top_path is None:
libs = get_mathlibs()
else:
path = join(split(build_dir)[0],'core')
libs = get_mathlibs(path)
libs = get_mathlibs()
tc = testcode_wincrypt()
if config_cmd.try_run(tc):
libs.append('Advapi32')
Expand Down

0 comments on commit c003f55

Please sign in to comment.