Issue 36269: post install in setup.py does not work when executed through pip (original) (raw)

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?

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)