def _InvokeBfint(Atoms, Bases, BasisLibs, BaseArgs, Outputs, Inputs=None):
    'Outputs: an array of tuples (cmdline-arguments,filename-base).\n   We will generate arguments for each of them and try to read the\n   corresponding files as numpy arrays and return them in order.'
    from tempfile import mkdtemp
    from shutil import rmtree
    from subprocess import check_output, CalledProcessError
    BasePath = mkdtemp(prefix='wmme.', dir=_TmpDir)

    def Cleanup():
        rmtree(BasePath)
        pass
    BfIntDir = _WmmeDir
    if (BfIntDir is None):
        BfIntDir = GetModulePath()
    BasisLibDir = _BasisLibDir
    if (BasisLibDir is None):
        BasisLibDir = path.join(BfIntDir, 'bases')
    MakeIntegralsExecutable = path.join(BfIntDir, 'wmme')
    FileNameXyz = path.join(BasePath, 'ATOMS')
    Args = [o for o in BaseArgs]
    Args.append('--matrix-format=npy')
    for BasisLib in BasisLibs:
        Args.append(('--basis-lib=%s' % path.join(BasisLibDir, BasisLib)))
    Args.append(('--atoms-au=%s' % FileNameXyz))
    iWrittenBasis = 0
    for (ParamName, BasisObj) in Bases.items():
        if (BasisObj is None):
            continue
        if isinstance(BasisObj, FBasisSet):
            BasisFile = path.join(BasePath, ('BASIS%i' % iWrittenBasis))
            iWrittenBasis += 1
            with open(BasisFile, 'w') as File:
                File.write(BasisObj.FmtCr())
            Args.append(("%s='!%s'" % (ParamName, BasisFile)))
        else:
            assert isinstance(BasisObj, str)
            Args.append(('%s=%s' % (ParamName, BasisObj)))
        pass
    FileNameOutputs = []
    for (ArgName, FileNameBase) in Outputs:
        FileName = path.join(BasePath, FileNameBase)
        FileNameOutputs.append(FileName)
        Args.append(("%s='%s'" % (ArgName, FileName)))
    XyzLines = ('%i\n\n%s\n' % (len(Atoms), Atoms.MakeXyz('%24.16f')))
    try:
        with open(FileNameXyz, 'w') as File:
            File.write(XyzLines)
        if Inputs:
            for (ArgName, FileNameBase, Array) in Inputs:
                FileName = path.join(BasePath, FileNameBase)
                np.save(FileName, Array)
                Args.append(("%s='%s'" % (ArgName, FileName)))
        Cmd = ('%s %s' % (MakeIntegralsExecutable, ' '.join(Args)))
        try:
            Output = check_output(Cmd, shell=True)
            if (version_info >= (3, 0)):
                Output = Output.decode('utf-8')
        except CalledProcessError as e:
            raise Exception(('Integral calculation failed. Output was:\n%s\nException was: %s' % (e.output, str(e))))
        OutputArrays = []
        for FileName in FileNameOutputs:
            OutputArrays.append(np.load(FileName))
    except:
        Cleanup()
        raise
    Cleanup()
    return tuple(OutputArrays)
Outputs: an array of tuples (cmdline-arguments,filename-base).
We will generate arguments for each of them and try to read the
corresponding files as numpy arrays and return them in order.
def _InvokeBfint(Atoms, Bases, BasisLibs, BaseArgs, Outputs, Inputs=None):
    'Outputs: an array of tuples (cmdline-arguments,filename-base).\n   We will generate arguments for each of them and try to read the\n   corresponding files as numpy arrays and return them in order.'
    from tempfile import mkdtemp
    from shutil import rmtree
    from subprocess import check_output, CalledProcessError
    BasePath = mkdtemp(prefix='wmme.', dir=_TmpDir)

    def Cleanup():
        rmtree(BasePath)
        pass
    BfIntDir = _WmmeDir
    if (BfIntDir is None):
        BfIntDir = GetModulePath()
    BasisLibDir = _BasisLibDir
    if (BasisLibDir is None):
        BasisLibDir = path.join(BfIntDir, 'bases')
    MakeIntegralsExecutable = path.join(BfIntDir, 'wmme')
    FileNameXyz = path.join(BasePath, 'ATOMS')
    Args = [o for o in BaseArgs]
    Args.append('--matrix-format=npy')
    for BasisLib in BasisLibs:
        Args.append(('--basis-lib=%s' % path.join(BasisLibDir, BasisLib)))
    Args.append(('--atoms-au=%s' % FileNameXyz))
    iWrittenBasis = 0
    for (ParamName, BasisObj) in Bases.items():
        if (BasisObj is None):
            continue
        if isinstance(BasisObj, FBasisSet):
            BasisFile = path.join(BasePath, ('BASIS%i' % iWrittenBasis))
            iWrittenBasis += 1
            with open(BasisFile, 'w') as File:
                File.write(BasisObj.FmtCr())
            Args.append(("%s='!%s'" % (ParamName, BasisFile)))
        else:
            assert isinstance(BasisObj, str)
            Args.append(('%s=%s' % (ParamName, BasisObj)))
        pass
    FileNameOutputs = []
    for (ArgName, FileNameBase) in Outputs:
        FileName = path.join(BasePath, FileNameBase)
        FileNameOutputs.append(FileName)
        Args.append(("%s='%s'" % (ArgName, FileName)))
    XyzLines = ('%i\n\n%s\n' % (len(Atoms), Atoms.MakeXyz('%24.16f')))
    try:
        with open(FileNameXyz, 'w') as File:
            File.write(XyzLines)
        if Inputs:
            for (ArgName, FileNameBase, Array) in Inputs:
                FileName = path.join(BasePath, FileNameBase)
                np.save(FileName, Array)
                Args.append(("%s='%s'" % (ArgName, FileName)))
        Cmd = ('%s %s' % (MakeIntegralsExecutable, ' '.join(Args)))
        try:
            Output = check_output(Cmd, shell=True)
            if (version_info >= (3, 0)):
                Output = Output.decode('utf-8')
        except CalledProcessError as e:
            raise Exception(('Integral calculation failed. Output was:\n%s\nException was: %s' % (e.output, str(e))))
        OutputArrays = []
        for FileName in FileNameOutputs:
            OutputArrays.append(np.load(FileName))
    except:
        Cleanup()
        raise
    Cleanup()
    return tuple(OutputArrays)