I want to be able to install some python code, using python-click and commands, with setup.py
. I have the following complete code:
import click
@click.group()
@click.option(
"-v",
"--verbose",
count=True,
default=0,
help="-v for DEBUG",
)
def cli(verbose):
print(verbose)
@cli.command("list")
@click.option(
"--option1"
)
def my_list_command(option1):
print(option1)
@cli.command("find")
@click.option(
"--option2"
)
def my_find_command(option2):
print(option2)
if __name__ == '__main__':
cli()
which defines two commands list
and find
. When I save that file as mycode.py
I can do for example
python mycode.py list --option1 opt1
python mycode.py find --option2 opt2
and the code works as expected, i.e. I have two commands with their options.
But when I now try to install this code with setup.py
as follows
from setuptools import setup, find_packages
setup(
name='MyCode',
install_requires=[
'click',
],
entry_points={
'console_scripts': [
'mytest=mycode.cli'
],
},
)
I get the error
ERROR: For req: MyCode==0.0.1. Invalid script entry point: <ExportEntry mytest = mycode.cli:None []> - A callable suffix is required. Cf https://packaging.python.org/specifications/entry-points/#use-for-scripts for more information.
How to properly setup a multi-command python-click code, so I can use it like the above examples?
from How to setup a python code with click with commands with setup.py?
No comments:
Post a Comment