问题
In Driver for pyodbc: how to specify its location in macOS?, TallTed suggested to open question to explain the following
Build pyodbc with links to iODBC (not its default of UnixODBC, which is not typical for macOS).
so now with the focus —
How can I build pyodbc with links to iODBC (not its default of UnixODBC, which is not typical for macOS)?
回答1:
This should/might work in 4.0.23, as it was the way it was done up to pyodbc v3.0.7:
First, in the file 'setup.py' change line 165 from:
settings['libraries'].append('odbc')
to:
settings['libraries'].append('iodbc')
Second, disable/delete lines 178, 179, and 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' ]
For reference, see the file 'setup.py' as of pyodbc 3.0.7 here, starting at line 146:
https://github.com/mkleehammer/pyodbc/blob/3.0.7/setup.py
Note: this will use the macos system supplied -- and presumably outdated -- libiodbc.dylib in /usr/lib. Not sure where the iODBC Framework installs the iODBC files, though. Maybe TallTed can comment on this?
来源:https://stackoverflow.com/questions/48084708/how-to-build-pyodbc-with-links-to-iodbc-in-macos