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.

classification
Title: post install in setup.py does not work when executed through pip
Type: behavior Stage: resolved
Components: Build Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: sabakauser
Priority: normal Keywords:

Created on 2019-03-12 12:29 by sabakauser, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg337736 - (view) Author: Saba Kauser (sabakauser) Date: 2019-03-12 12:29
Hello,

I have a post install class that looks like this:
if('darwin' in sys.platform):
    class PostInstall(install):
        """ Post installation - run install_name_tool on Darwin """
        def run(self):
            clipath = os.getenv('IBM_DB_HOME', '@loader_path/clidriver')
            print("in PostInstall with {}".format(clipath))
            for so in glob.glob(r'build/lib*/ibm_db*.so'):
                os.system("install_name_tool -change libdb2.dylib {}/lib/libdb2.dylib {}".format(clipath, so))
            install.run(self)
    cmd_class = dict(install = PostInstall)

	
And I pass cmd_class to setup(..) as:
setup(..
      include_package_data = True,
       cmdclass = cmd_class,
       **extra
     )

When I execute setup.py as "python setup.py install", then the PostInstall operation is executed after the ibm_db.so is built and installed and I see the intended result. 
However, when I run "pip install ibm_db" or "pip install .",
the execution order looks like this:
    warnings.warn(notifyString)
    running install
    in PostInstall with /Applications/dsdriver/  ==> this is my post install script
    running build
    running build_py
    creating build	
    creating build/lib.macosx-10.9-x86_64-3.7	 ==> I need to traverse to this folder to find my shared library
	
I would expect it to be run post the ibm_db is installed, not before it gets built. 

Can you please let me know how can this be fixed. Is this a bug with pip?
msg337850 - (view) Author: Saba Kauser (sabakauser) Date: 2019-03-13 13:22
I am able to get this to work.
I just needed to invoke parent's run prior to the post install commands.

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(r'build/lib*/ibm_db*.so'):
                os.system("install_name_tool -change libdb2.dylib {}/lib/libdb2.dylib {}".format(clipath, so))
            
    cmd_class = dict(install = PostInstall)
History
Date User Action Args
2022-04-11 14:59:12adminsetgithub: 80450
2019-03-13 13:23:05sabakausersetstatus: open -> closed
stage: resolved
2019-03-13 13:22:54sabakausersetresolution: fixed
messages: + msg337850
2019-03-12 12:29:27sabakausercreate