Difference between pip3 and `python3 setup.py install` regarding cmdclass argument

Viewed 5655

I tried to configure my package such that a script is executed on the installation process. Therefore, I inherited from setuptools.command install and created my custom class ActionOnInstall to do stuff when package is installed. This class is called via setuptools setup() argument cmdclass as described here.

A minimal example of such a setup.py file looks like

from setuptools import find_packages, setup
from setuptools.command.install import install


class ActionOnInstall(install):
    def run(self):
        print("Call install.run(self) works!")
        install.run(self)


setup(name='name',
      cmdclass={
      'install': ActionOnInstall})

Building the package by executing

pip3 install <path-to-dir-with-setup.py>

runs successfully but does not execute commands specified in ActionOnInstall.run(). More directly calling this setup.py by

python3 setup.py install 

executes commands specified in ActionOnInstall.run().

Then, I found myself asking: what is the actual difference of these both approaches to install a package. I know, like other posts tell us, pip makes life easier regarding package installation. But how these both approaches treat the cmdclass argument of setup() differently is not explained. Thus, I would highly appreciate to hear from you guys.

2 Answers
Related