(Solved) Pyodbc install fails

Currently working on setting up a django app that needs a mssql database connection. The mssql library (posted below) operates off of Pyodbc. Pyodbc has a requirement of unixodbc. Unfortunately, Im having issues with getting this requirement installed.



http://www.unixodbc.org/

Currently trying to following to get the dependency installed.

export LD_LIBRARY_PATH=$LIBDIR:/app/unixODBC-2.3.7
    wget http://www.unixodbc.org/unixODBC-2.3.7.tar.gz
    gunzip unixODBC*.tar.gz
    tar xvf unixODBC*.tar
    cd unixODBC*
    mkdir /app/unixODBC-2.3.7/etc
    ./configure --prefix=/app/unixODBC-2.3.7 --sysconfdir=/app/unixODBC-2.3.7
    make
    make install

The last error Im getting is below.

make[2]: Nothing to be done for 'install-exec-am'.
     /bin/mkdir -p '/app/unixODBC-2.3.7/include'
     /usr/bin/install -c -m 644 odbcinst.h odbcinstext.h sql.h sqlext.h sqltypes.h sqlucode.h sqlspi.h autotest.h uodbc_stats.h uodbc_extras.h '/app/unixODBC-2.3.7/include'
    W: /usr/bin/install: 'odbcinst.h' and '/app/unixODBC-2.3.7/include/odbcinst.h' are the same file
    W: /usr/bin/install: 'odbcinstext.h' and '/app/unixODBC-2.3.7/include/odbcinstext.h' are the same file
    W: /usr/bin/install: 'sql.h' and '/app/unixODBC-2.3.7/include/sql.h' are the same file
    W: /usr/bin/install: 'sqlext.h' and '/app/unixODBC-2.3.7/include/sqlext.h' are the same file
    W: /usr/bin/install: 'sqltypes.h' and '/app/unixODBC-2.3.7/include/sqltypes.h' are the same file
    W: /usr/bin/install: 'sqlucode.h' and '/app/unixODBC-2.3.7/include/sqlucode.h' are the same file
    W: /usr/bin/install: 'sqlspi.h' and '/app/unixODBC-2.3.7/include/sqlspi.h' are the same file
    W: /usr/bin/install: 'autotest.h' and '/app/unixODBC-2.3.7/include/autotest.h' are the same file
    W: /usr/bin/install: 'uodbc_stats.h' and '/app/unixODBC-2.3.7/include/uodbc_stats.h' are the same file
    W: /usr/bin/install: 'uodbc_extras.h' and '/app/unixODBC-2.3.7/include/uodbc_extras.h' are the same file
    W: make[2]: *** [install-includeHEADERS] Error 1
    Makefile:409: recipe for target 'install-includeHEADERS' failed
    make[2]: Leaving directory '/app/unixODBC-2.3.7/include'
    W: make[1]: *** [install-am] Error 2
    Makefile:525: recipe for target 'install-am' failed
    make[1]: Leaving directory '/app/unixODBC-2.3.7/include'
    W: make: *** [install-recursive] Error 1
    Makefile:548: recipe for target 'install-recursive' failed

Any help with getting this dependency installed would be much appreciated.

After debugging and testing with the PSH support team, I was able to get a passing build

@matthias-van-woensel suggested utilizing brew for managing the dependencies, and following was my build set for this to work.


Edit:
After this post, I found a new flaw in my approach. I planned to use the Microsoft ODBC driver that is available via Debian package. This brought up the new concern of not being able to use Debian package managers in the PSH environment. I also had some troubles shipping the driver right in my repo, but the details below will mention how to debug the driver issues.
https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15#microsoft-odbc-driver-17-for-sql-server

I was not previous aware of FreeTDS. FreeTDS is an open source ODBC Sql Server driver.
http://www.freetds.org/

Fortunately, like the unixODBC driver manage, this driver is available through homebrew. Below is my final build hook step to install all dependancies to connect to a Sql Server instance from a PSH python container.

Below is the .odbc.ini file I used to tell register my FreeTDS driver with unixODBC that pyodbc will register. Location of this file can suit your preference, but update your build hook to match any change in location.

Final Build Hook:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
    echo 'eval $(/app/.linuxbrew/bin/brew shellenv)' >>~/.profile
    eval $(/app/.linuxbrew/bin/brew shellenv)
    brew analytics off
    brew install gcc
    brew install openssl
    brew install freetds
    brew install unixodbc
    odbcinst -i -d -f /app/.odbc.ini
    pipenv install --system --deploy
    mkdir .ssh

.odbc.ini

[FreeTDS]
Description	= TDS driver (Sybase/MS SQL)
Driver		= /app/.linuxbrew/lib/libtdsodbc.so
1 Like