""" Tools for building F2PY generated extension modules. ----- Permission to use, modify, and distribute this software is given under the terms of the NumPy License. See http://scipy.org. NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. Author: Pearu Peterson Created: Oct 2006 ----- """ import os import re import sys import tempfile try: from numpy import __version__ as numpy_version except ImportError: numpy_version = 'N/A' __all__ = ['main'] __usage__ = """ F2PY G3 --- The third generation of Fortran to Python Interface Generator ========================================================================= Description ----------- f2py program generates a Python C/API file (module.c) that contains wrappers for given Fortran functions and data so that they can be accessed from Python. With the -c option the corresponding extension modules are built. Options ------- --3g-numpy Use numpy.f2py.lib tool, the 3rd generation of F2PY, with NumPy support. --2d-numpy Use numpy.f2py tool with NumPy support. [DEFAULT] --2d-numeric Use f2py2e tool with Numeric support. --2d-numarray Use f2py2e tool with Numarray support. """ import re import shutil from parser.api import parse, PythonModule, EndStatement, Module, Subroutine, Function def get_values(sys_argv, prefix='', suffix='', strip_prefix=False, strip_suffix=False): """ Return a list of values with pattern . The corresponding items will be removed from sys_argv. """ match = re.compile(prefix + r'.*' + suffix + '\Z').match ret = [item for item in sys_argv if match(item)] [sys_argv.remove(item) for item in ret] if strip_prefix and prefix: i = len(prefix) ret = [item[i:] for item in ret] if strip_suffix and suffix: i = len(suffix) ret = [item[:-i] for item in ret] return ret def get_option(sys_argv, option, default_return = None): """ Return True if sys_argv has