This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author sabakauser
Recipients sabakauser, xtreak
Date 2019-04-22.05:42:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1555911751.94.0.805223478388.issue36640@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2019-04-22 05:42:31sabakausersetrecipients: + sabakauser, xtreak
2019-04-22 05:42:31sabakausersetmessageid: <1555911751.94.0.805223478388.issue36640@roundup.psfhosted.org>
2019-04-22 05:42:31sabakauserlinkissue36640 messages
2019-04-22 05:42:31sabakausercreate