Justin Furuness
Justin Furuness

Reputation: 986

How to add console_script/entry point to setup.py that call a class function python

I want to add an entry point to setup.py that calls a static method of a class. Is that possible, and if so how? I've tried, and looked up documentation, but can not figure out how to do it.

Example: Package format:

mypackage/
   setup.py
   mypackage/
      test.py

test.py contains:

class TestClass:
   @staticmethod
   test_func():
      print("test print statement")

setup.py contains console scripts that look like:

entry_points={
        'console_scripts': [
            'run_console_script = mypackage.test:TestClass.test_func'
         ]}

But when I run the above code, it doesn't error, and yet nothing is printed.

Upvotes: 3

Views: 2540

Answers (1)

sinoroc
sinoroc

Reputation: 22305

According to setuptools' documentation on "Automatic Script Creation" entry-points can only be functions:

The way to use this feature is to define “entry points” in your setup script that indicate what function the generated script should import and run.

Upvotes: 2

Related Questions