Conditional setuptools entry_points

Viewed 1351

Is it possible to have conditional entry_points defined in setup.py? I noticed that it is possible to tag an entry point using extras, but that entry point will be available even if the package is installed without that extra feature.

setup(name='my.package',
      ...
      extras_require={
          'special': [
              'dependency1',
              'dependency2',
          ],
      },
      ...
      entry_points="""
      [custom_entrypoint]
      handlername = my.package.special:feature [special]
      """,
  )

It appears as that custom_entrypoint is available even if the package is installed without that special feature (pip install my.package[special]). Is there a simple way of getting something like this working?

2 Answers
Related