Search code examples
pythonsetuptoolsckan

Python setup.py entry_points syntax with triple single quotes


I'm looking at extensions for CKAN, and their entry_points entries look like this:

setup(
    #...,
    entry_points='''
        [ckan.plugins]
        template=ckanext.template.plugin:TemplatePlugin

        [babel.extractors]
        ckan = ckan.lib.extract:extract_ckan

        [paste.paster_command]
        template=ckanext.template.commands.custom_commands:CustomCommand

    ''',
    #...,
)

I'm trying to upgrade an existing extension that uses CKAN's CLI. The 3rd entry above is for a CLI command. I'm trying to update it for CKAN's latest version that no longer uses Paster, but uses Click instead.

I'm trying to tell how to update [paste.paster_command], but I can't find references to anything else using this entry_points syntax to be certain how to update it. For any reference to setup.py syntax I can find, it looks like below (from Click's documentation, in this case):

setup(
    #...,
    entry_points={
        'console_scripts': [
            'yourscript = yourpackage.scripts.yourscript:cli',
        ],
    },
)

The setuptools documentation only references entry_points in relation to setup.cfg. So the examples of entry_points in their docs are unhelpful. Therefore, given what I can find, I have to assume for the triple-quote syntax above that it's just regular Python string formatting, and the square brackets are the "dependency extra". True? If not, what are they? Any reference to this "alternate" string syntax would be appreciated.


Solution

  • Per response from Zharktas on CKAN's GitHub discussion board:

    The syntax is in .ini-style: https://setuptools.readthedocs.io/en/latest/pkg_resources.html#creating-and-parsing "If data is a string or sequence of lines, it is first split into .ini-style sections (using the split_sections() utility function) and the section names are used as group names."

    Click commands implemented with IClick interface do not require entry in entry_points anymore as they are executed through the new ckan command instead of paster which required that you tell paster about them via entry_points.

    You can just remove whole entry if you want to support only CKAN 2.9.