[issue36640] python ibm_db setup.py post install script does not seem to work from Anaconda

Saba Kauser report at bugs.python.org
Mon Apr 22 01:42:31 EDT 2019


Saba Kauser <skauseribmdb at gmail.com> added the comment:

I have debugged this further.
The problem seems be happening due to usage of get_python_lib().

e.g:
if('darwin' in sys.platform):
    class PostInstall(install):
        """ Post installation - run install_name_tool on Darwin """
        def run(self):
            install.run(self)
            clipath = os.getenv('IBM_DB_HOME', '@loader_path/clidriver')
            print("in PostInstall with {}".format(clipath))
            for so in glob.glob(get_python_lib()+r'/ibm_db*.so'):
                os.system("install_name_tool -change libdb2.dylib {}/lib/libdb2.dylib {}".format(clipath, so))

cmd_class = dict(install = PostInstall)

The get_python_lib() returns following path and hence my script is never able to fetch the matching lib name.
example output of get_python_lib() usage:
    /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/Users/skauser/anaconda3/lib/python3.7/site-packages/CHANGES
    /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/Users/skauser/anaconda3/lib/python3.7/site-packages/LICENSE
    /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/Users/skauser/anaconda3/lib/python3.7/site-packages/README.md
    /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/Users/skauser/anaconda3/lib/python3.7/site-packages/config.py.sample


I have both anaconda and standalone python installations and get_python_lib() seem to get confused with different paths.
It sometimes returns the duplicate path as well:
e.g: 
    /Users/skauser/anaconda3/lib/python3.7/site-packages/Users/skauser/anaconda3/lib/python3.7/site-packages/CHANGES
    /Users/skauser/anaconda3/lib/python3.7/site-packages/Users/skauser/anaconda3/lib/python3.7/site-packages/LICENSE
    /Users/skauser/anaconda3/lib/python3.7/site-packages/Users/skauser/anaconda3/lib/python3.7/site-packages/README.md
    /Users/skauser/anaconda3/lib/python3.7/site-packages/Users/skauser/anaconda3/lib/python3.7/site-packages/config.py.sample

Above examples are taken from one usage of get_python_lib() for copying certain data files while installation to site-packages. 
My strong belief is that, its the same problem with the post-install script as well.

Why is get_python_lib() behavior not consistent? 
What are the other alternatives to get the current site-package path for the running installation?

When I disable cache of pip and install, get_python_lib() path as retrieved while install behaves correctly.
e.g: pip --no-cache-dir install ibm_db

Kindly help! This is blocking production of many users.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36640>
_______________________________________


More information about the Python-bugs-list mailing list