diff options
author | Pauli Virtanen <pav@iki.fi> | 2019-12-14 15:31:50 +0200 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2019-12-14 17:09:06 +0200 |
commit | 5a4f62bbf7622530e2a43d1859ae496537e9f0f0 (patch) | |
tree | 12bab1afefe906e715991df5a94786e478d27954 /numpy/f2py/tests/util.py | |
parent | b6f91207549fc97765c114c0c01625eaa5e58956 (diff) | |
download | numpy-5a4f62bbf7622530e2a43d1859ae496537e9f0f0.tar.gz |
ENH: f2py: add --f2cmap option for specifying the name of .f2py_f2cmap
Previously, f2py loaded the type mappings from a file ``.f2py_f2cmap``
in current directory, at import time.
Make the file name customizable by adding a ``--f2cmap`` command line
option, and postpone loading the file to f2py.run_main().
Moreover, restore the default type mapping in f2py.run_main() before
loading the customizations, so that multiple calls to f2py.run_main() do
not interfere with each other. (For example, numpy.distutils calls f2py
multiple times in the same process.)
Diffstat (limited to 'numpy/f2py/tests/util.py')
-rw-r--r-- | numpy/f2py/tests/util.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/numpy/f2py/tests/util.py b/numpy/f2py/tests/util.py index 77cb612d0..8211a63f0 100644 --- a/numpy/f2py/tests/util.py +++ b/numpy/f2py/tests/util.py @@ -107,6 +107,7 @@ def build_module(source_files, options=[], skip=[], only=[], module_name=None): # Copy files dst_sources = [] + f2py_sources = [] for fn in source_files: if not os.path.isfile(fn): raise RuntimeError("%s is not a file" % fn) @@ -114,16 +115,14 @@ def build_module(source_files, options=[], skip=[], only=[], module_name=None): shutil.copyfile(fn, dst) dst_sources.append(dst) - fn = os.path.join(os.path.dirname(fn), '.f2py_f2cmap') - if os.path.isfile(fn): - dst = os.path.join(d, os.path.basename(fn)) - if not os.path.isfile(dst): - shutil.copyfile(fn, dst) + base, ext = os.path.splitext(dst) + if ext in ('.f90', '.f', '.c', '.pyf'): + f2py_sources.append(dst) # Prepare options if module_name is None: module_name = get_temp_module_name() - f2py_opts = ['-c', '-m', module_name] + options + dst_sources + f2py_opts = ['-c', '-m', module_name] + options + f2py_sources if skip: f2py_opts += ['skip:'] + skip if only: |