Perform a command after pip install <package>
Asked Answered
E

0

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.

Exchange answered 24/4, 2018 at 5:38 Comment(10)
I tried to follow this #20289211 where the same approach is used using setup.toolsExchange
if post-install scripts are not supported in wheel are there any other alternatives ?Exchange
Call the post-install script manually. Or use a native package format (deb, rpm) instead of sdist.Respiration
Well, in sdist you can implement post-install by running code after install.run(self). But not in a wheel.Respiration
adding stuff after install.run(self) is not called eitherExchange
if i do python setup.py install , it gets called but using pip install noExchange
Strange. For an sdist pip install runs python setup.py install. What code did you try? Was it print?Respiration
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.Exchange
Possible duplicate of Post install script after installing a wheelFalcongentle
@Respiration 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.Exchange

© 2022 - 2024 — McMap. All rights reserved.