6

I bundle my package as a sdist zip file , after that i can import my package anywhere using pip install , but i want to run some post install commands automatically after calling pip install. I cannot use python setup.py install because it is a sdist and i am using pip to install it . I do have a PostInstall class but nothing runs after pip install package. Is there a way to automatically run a script after pip install package. I have tried using postinstall but it doesnt work and also i am not sure how to use the scripts atrib in the setup method.

This is my setup.py file : Setup.py

I cannot use python setup.py install because it is a sdist and i am using pip to install it . I do have a MyInstall class but nothing run after pip install package.

Sajid Manzoor
  • 487
  • 1
  • 5
  • 9
  • I tried to follow this https://stackoverflow.com/questions/20288711/post-install-script-with-python-setuptools where the same approach is used using setup.tools – Sajid Manzoor Apr 24 '18 at 05:49
  • if post-install scripts are not supported in wheel are there any other alternatives ? – Sajid Manzoor Apr 24 '18 at 07:01
  • Call the post-install script manually. Or use a native package format (deb, rpm) instead of sdist. – phd Apr 24 '18 at 07:35
  • 1
    Well, in sdist you can implement post-install by running code after `install.run(self)`. But not in a wheel. – phd Apr 24 '18 at 07:37
  • adding stuff after install.run(self) is not called either – Sajid Manzoor Apr 24 '18 at 08:13
  • if i do python setup.py install , it gets called but using pip install no – Sajid Manzoor Apr 24 '18 at 08:19
  • Strange. For an sdist `pip install` runs `python setup.py install`. What code did you try? Was it `print`? – phd Apr 24 '18 at 14:30
  • what i meant was the the post-install script is being called if i use python setup.py install lets say for a bdist, but after that when i package it as a sdist and try to install using pip , it does not work , im not trying a print statement , i try to create a directory structure at the install location. – Sajid Manzoor Apr 25 '18 at 02:58
  • Possible duplicate of [Post install script after installing a wheel](https://stackoverflow.com/questions/24263774/post-install-script-after-installing-a-wheel) – hoefling Apr 26 '18 at 19:13
  • @phd yep thats right, however for wheel i was able to pass a script in the setup.py scripts option, which is passed where ever i pip install the proj and can be executed manually. – Sajid Manzoor Jun 06 '18 at 04:25

0 Answers0