when I use the pip install my_custom_package.whl, the pip does not trigger cmdclass={'install': MyInstall}
How can I get pip to trigger cmdclass of setup() ?
@bohblue2 This is not possible because setup.py is not executed when installing from a .whl (which is a desirable state of affairs).
The way it works is that the installation is broken into two steps - first the package source is built into a wheel (at which point setup.py is executed), which is a zip file containing metadata and all the files to be installed on the target, then the wheel is installed by unzipping the wheel into the correct place. No post-install step can be executed.
When you build a wheel and then install it directly, you never execute setup.py, because the first step has already been done for you. This is desirable for a number of reasons, one of which is that it's very fast and easy to install from a wheel (just decompress the archive into the right place and install the metadata), whereas installing from a source distribution can be more time consuming (particularly if a compilation step is involved).
Ideally, the solution to your problem is to design your build step with this in mind and not rely on any sort of post-installation logic. If you need help in figuring this out, I recommend formulating a question suitable for Stack Overflow and posting it there - if you do this, feel free to post the link to the SO question in this issue. I think doing so will get you a much wider audience.
I'm closing this issue for now, because this is not an issue to track so much as a question.
Most helpful comment
@bohblue2 This is not possible because
setup.pyis not executed when installing from a.whl(which is a desirable state of affairs).The way it works is that the installation is broken into two steps - first the package source is built into a wheel (at which point
setup.pyis executed), which is a zip file containing metadata and all the files to be installed on the target, then the wheel is installed by unzipping the wheel into the correct place. No post-install step can be executed.When you build a wheel and then install it directly, you never execute
setup.py, because the first step has already been done for you. This is desirable for a number of reasons, one of which is that it's very fast and easy to install from a wheel (just decompress the archive into the right place and install the metadata), whereas installing from a source distribution can be more time consuming (particularly if a compilation step is involved).Ideally, the solution to your problem is to design your build step with this in mind and not rely on any sort of post-installation logic. If you need help in figuring this out, I recommend formulating a question suitable for Stack Overflow and posting it there - if you do this, feel free to post the link to the SO question in this issue. I think doing so will get you a much wider audience.
I'm closing this issue for now, because this is not an issue to track so much as a question.