summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorDavid Cournapeau <cournape@gmail.com>2009-07-26 11:16:24 +0000
committerDavid Cournapeau <cournape@gmail.com>2009-07-26 11:16:24 +0000
commit5b5f879bb6c585f469d4986cec5d528627d55415 (patch)
tree5a7b2f0ab7d986b2404963170bfd9f56a9aed390 /numpy/core
parentd04e38647123c30e551dbbb5d947d0379bb4bec0 (diff)
downloadnumpy-5b5f879bb6c585f469d4986cec5d528627d55415.tar.gz
Refactor a bit the code to generate npymath.ini.
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/mlib.ini.in10
-rw-r--r--numpy/core/setup.py51
2 files changed, 41 insertions, 20 deletions
diff --git a/numpy/core/mlib.ini.in b/numpy/core/mlib.ini.in
new file mode 100644
index 000000000..bf72f2a6c
--- /dev/null
+++ b/numpy/core/mlib.ini.in
@@ -0,0 +1,10 @@
+[meta]
+Name = mlib
+Description = Math library used with this version of numpy
+Version = 1.0
+
+[default]
+Libs=@posix_mathlib@
+
+[msvc]
+Libs=@msvc_mathlib@
diff --git a/numpy/core/setup.py b/numpy/core/setup.py
index d32584046..b8d855b6b 100644
--- a/numpy/core/setup.py
+++ b/numpy/core/setup.py
@@ -635,31 +635,42 @@ def configuration(parent_package='',top_path=None):
def inplace_build():
return get_cmd('build_ext').inplace == 1
- def install_npymath_ini(install_dir):
- npymath_install_dir = os.path.join(install_dir, 'numpy', 'core')
- npymath_install_dir = os.path.abspath(npymath_install_dir)
+ def install_npymath_ini(target, source, top_prefix):
+ top_prefix = os.path.abspath(os.path.join(top_prefix))
+ prefix = os.path.join(top_prefix, 'numpy', 'core')
+ d = {'install_dir': prefix, 'sep': os.path.sep}
- d = os.path.join(build_dir, 'numpy', 'core', 'lib', 'npy-pkg-config')
- if not os.path.exists(d):
- os.makedirs(d)
- filename = os.path.join(d, 'npymath.ini')
- d = {'install_dir': npymath_install_dir, 'sep': os.path.sep}
- subst_vars(filename, 'numpy/core/npymath.ini.in', d)
- return filename
+ subst_vars(target, source, d)
+ return target
+
+ # install_dir relative to current package build directory
+ install_dir = 'lib/npy-pkg-config'
+ template = 'npymath.ini.in'
+
+ basename = os.path.splitext(template)[0]
+ pkg_path = config.local_path
+ template = os.path.join(pkg_path, template)
+
+ # where to put the generated file
+ target_dir = os.path.join(build_dir, pkg_path, install_dir)
+ if not os.path.exists(target_dir):
+ os.makedirs(target_dir)
+ generated = os.path.join(target_dir, basename)
install_cmd = get_cmd('install')
if hasattr(install_cmd, 'install_libbase'):
- install_dir = install_cmd.install_libbase
- source = install_npymath_ini(install_dir)
- config.add_data_files(('lib/npy-pkg-config', source))
+ top_prefix = install_cmd.install_libbase
+ source = install_npymath_ini(generated, template, top_prefix)
+ config.add_data_files((install_dir, source))
elif inplace_build():
- install_dir = '.'
- source = install_npymath_ini(install_dir)
- target = os.path.join('numpy', 'core', 'lib', 'npy-pkg-config',
- os.path.basename(source))
- if not os.path.exists(os.path.dirname(target)):
- os.makedirs(os.path.dirname(target))
- shutil.copy(source, target)
+ top_prefix = '.'
+ generated = install_npymath_ini(generated, template, top_prefix)
+
+ # Copy the generated file into the source tree
+ installed = os.path.join(pkg_path, install_dir, basename)
+ if not os.path.exists(os.path.dirname(installed)):
+ os.makedirs(os.path.dirname(installed))
+ shutil.copy(generated, installed)
config.add_installed_library('npymath',
sources=[join('src', 'npymath', 'npy_math.c.src'),