如何在 macOS 中构建带有 iODBC 链接的 pyodbc?

How to build pyodbc with links to iODBC in macOS?

Driver for pyodbc: how to specify its location in macOS?, TallTed建议开题解释如下

Build pyodbc with links to iODBC (not its default of UnixODBC, which is not typical for macOS).

所以现在有了重点——

如何构建带有 iODBC 链接的 pyodbc(不是默认的 UnixODBC,这对于 macOS 来说不是典型的)?

这个 should/might 在 4.0.23 中工作,因为它是 pyodbc v3.0.7 之前完成的方式:

首先,在文件 setup.py 中,将第 165 行从 --

更改为
    settings['libraries'].append('odbc')

-- 到 --

    settings['libraries'].append('iodbc')

其次,disable/delete 第 178、179 和 183 行。

        # Add directories for MacPorts and Homebrew.
#       dirs = ['/usr/local/include', '/opt/local/include','~/homebrew/include']
#       settings['include_dirs'].extend(dir for dir in dirs if isdir(dir))

        # unixODBC make/install places libodbc.dylib in /usr/local/lib/ by default
        # ( also OS/X since El Capitan prevents /usr/lib from being accessed )
#       settings['library_dirs'] = [ '/usr/local/lib' ]

作为参考,请参阅 file setup.py as of pyodbc 3.0.7,从第 146 行开始

注意:这将使用 /usr/lib 中提供的 macos 系统——可能已经过时了——libiodbc.dylib。不确定 iODBC Framework installs the iODBC files, though. Maybe TallTed 可以在哪里发表评论?