Search code examples
pythonsetuptoolsentry-point

Why does setuptools not create my entry points?


My project directory structure looks like this:

clc
 |-clc
 |  |-__init__.py
 |  |-clc.py
 |  |-main.py
 |-setup.py

main.py looks like this:

def main():
    print "it works!"

in setup.py:

config = {
    ...
    'entry_points':
        'clc_scripts': ['clc = clc.main:main']
    }
}
setup(**config)

When I run python setup.py build, I end up with the following:

running build
running build_py
creating build
creating build/lib
creating build/lib/clc
copying clc/__init__.py -> build/lib/clc
copying clc/clc.py -> build/lib/clc
copying clc/main.py -> build/lib/clc

No bin folder is created, even though I specified an entry point. It does create a file clc.egg-info/entry_points.txt:

$ cat clc.egg-info/entry_points.txt
[clc_scripts]
clc = clc.main:main

Why did setuptools not create my entry point executable file?


Solution

  • 1) The entry point for generating scripts is called console_scripts.

    So fix the name of the entry point in your setup.py like this:

    config = {
        ...
        'entry_points':
            'console_scripts': ['clc = clc.main:main']
        }
    }
    

    2) Entry points won't get executed when you just build your distribution. They really only make sense for install or develop. Try python setup.py install.