Yes, this is 2015 and the documentation for adding commands and options to setuptools and distutils is still mostly missing.
After several disappointing hours, I figured out the following code to add a custom option to the install setup.py command:
from setuptools.command.install import install class InstallCommand(install): user_options = install.user_options + [ ('custom_option=', None, 'Path to something') ] def initialize_options(self): install.initialize_options(self) self.custom_option = None def finalize_options(self):
It is worth noting that install.run () checks whether it was called "originally" or was fixed:
if not self._called_from_setup(inspect.currentframe()): orig.install.run(self) else: self.do_egg_install()
At this point, you register your command with setup :
setup( cmdclass={ 'install': InstallCommand, }, :
Ronen Botzer Oct 17 '15 at 0:21 2015-10-17 00:21
source share