Att Righ
Att Righ

Reputation: 1789

How do I create a python setuptools entrypoint for package.__main__?

I want to have a directory structure like so:

package
package/__init__.py
package/__main__.py
setup.py

And use package.__main__ as a entry point

setuptools.setup(
    name="package",
    version=0.1,
    ...
    entry_points={"console_scripts": ["llmcli=llmcli"]},
)

Can I set entrypoints to do this?

Upvotes: 1

Views: 403

Answers (1)

Stefan van der Walt
Stefan van der Walt

Reputation: 7253

The easiest is to refactor your __main__.py slightly, so that it calls a main function internally:

def main():
    ...

if __name__ == "__main__":
    main()

Then you can add it as an entrypoint as mymodule.__main__:main.

Upvotes: 3

Related Questions