import os from setuptools import setup from setuptools.command.install import install class CustomInstallCommand(install): def run(self): install.run(self) # Run the post-install script os.system('python post_install.py') requirement_path = "requirements.txt" install_requires = [] if os.path.isfile(requirement_path): with open(requirement_path) as f: install_requires = f.read().splitlines() setup( name="mypackage", install_requires=install_requires, cmdclass={ 'install': CustomInstallCommand, }, # ... other setup options ... )