简体   繁体   中英

Specifying command line scripts in pyproject.toml

I'm trying to add a pyproject.toml to a project that's been using setup.py in order to enable support by pipx. I'd like to specify the command line scripts the project includes in pyproject.toml, but all the guides I can find give instructions for use with poetry, which I am not using.

I also don't want to specify entry points to modules - I already have working command line scripts and just want to specify those.

Is there a proper place in pyproject.toml to specify command line scripts?

Not sure it matters, but the package in question is cutlet .

Is there a proper place in pyproject.toml to specify command line scripts?

PEP566 (Metadata 2.1) only defines Core metadata specifications . Thus, the answer depends on your build system (Note: PEP518 defines build system concept ).

If you use the existing build tools such as setuptools , poetry , and flit , you only can consider adding such options in pyproject.toml if that tool supports command line scripts ( console_scripts ) in pyproject.toml . Surely, if you have your own build tool, you need to implement a parser to parse the command line scripts in pyproject.toml .

Lastly, you can check below list to know which major build system supports command line scripts ( console_scripts ) in pyproject.toml (2020/Oct):

Update July 2022: setuptools will happily install a console script if file pyproject.toml has an entry like this:

[project.scripts]
my-client = "my_package.my_module:main_cli"

FWIW I was doing the same thing, upgrading a package that had a setup.py ; with the rewrite to pyproject.toml I dropped the old file entirely.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM