Search code examples
pythonpython-2.7setuptoolssetup.py

How to add a command hook into setuptools setup?


I am using setuptools Version 0.9.6 and want to add a command hook into setup, following the description shown here or here. I have created a class MyCommand derived from setuptools.Command within the same setup.py file and I am trying to add this hook as follows:

setup(
  # ...
  entry_points = {
    "distutils.commands": [
      "my_command = MyCommand"]}
)

However, the command my_command is not recognized, i.e. python setup.py my_command gives an error

error: invalid command 'my_command'

Maybe I do need to refer to my command in a different way? Or are there changes to the used version 0.9.6 of setuptools? How to do it right?


Solution

  • Add your command in cmdclass instead thats what i found.

    setup(
    cmdclass = {'my_command':MyCommand},
    )
    

    Type :

    >>> python setup.py --help-commands
    

    Will list your command in Extra Commands