I tried to configure my package so that the script was executed during the installation process. So I inherited from setuptools.command install and created my own ActionOnInstall class to do things when the package is installed. This class is called through the 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 a package by doing
pip3 install <path-to-dir-with-setup.py>
succeeds but does not execute the commands specified in ActionOnInstall.run() . More direct access to this setup.py with
python3 setup.py install
executes the commands specified in ActionOnInstall.run() .
Then I found out that I was asking: what is the actual difference between the two approaches for installing the package. I know that, like other posts, pip code makes package installation easier. But how these two approaches relate to the cmdclass setup() argument differently is not explained. So, I would be very happy to hear from you guys.
python installation pip package setuptools
gplssm
source share