Does python's setuptools support the `__name__ == “__main__”` style of execution?

I'm just getting into packaging with setuptools, and it seems that the recommended way to install a python script along with one's module is to specify a script name that calls the name of a function, like this:

setup(
    # ...
    entry_points = {
        "console_scripts": [
            "script_name": "project.main:main",
        ],
    }
)

This clearly precludes the standard way of making a python module executable, which is (last time I checked, which was a while ago) to use if __name__ == "__main__": do_stuff(). Does setuptools support this style, or should I switch to defining a main function and specifying it in entry_points?

9
задан Ryan Thompson 10 April 2011 в 11:59
поделиться