Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup entry_points in setup.cfg

I am moving my config from setup.py to setup.cfg and having issues setting up the entry_points parameter. At the moment I am using a hybrid approach which works, however, I would like to move the entry_points to setup.cfg.

From

def setup_package():     setup(version=get_version(),           entry_points={'console_scripts':['app=my_package.app.run:cli'],}) 

to

[metadata] name = my-package description = my-package license = unlicensed long-description = README.md platforms = any classifiers =   Programming Language :: Python  [options] zip_safe = False packages = my_package,  my_package.app include_package_data = True package_dir =   = . tests_require = pytest; pytest-cov  [entry_points] console_scripts =   my-package = my_package.app.run:cli 
like image 247
user465374 Avatar asked Feb 20 '18 11:02

user465374


People also ask

What is Entry_points in setup py?

Entry points are a type of metadata that can be exposed by packages on installation. They are a very useful feature of the Python ecosystem, and come specially handy in two scenarios: 1. The package would like to provide commands to be run at the terminal. This functionality is known as console scripts.

Do you need setup py If you have setup CFG?

you must have a valid setup.py file apart from setup. cfg and pyproject. toml . You can use the same dummy setup file I shared in the previous section that makes just a single call to the setup() method.

Is setup CFG deprecated?

Nope, setup. cfg it is not deprecated and the documentation you mention is misleading. There were serious reasons like security related to the fact that setup.py needed execution and that's the main reason of moving away from it.

Is setup py outdated?

py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. I found a very detailed write-up explaining this issue: "Why you shouldn't invoke setup.py directly" (October 2021).


1 Answers

The section must be [options.entry_points]. See an example at https://github.com/github/octodns/blob/4b44ab14b1f0a52f1051c67656d6e3dd6f0ba903/setup.cfg#L34

[options.entry_points] console_scripts =     octodns-compare = octodns.cmds.compare:main     octodns-dump = octodns.cmds.dump:main     octodns-report = octodns.cmds.report:main     octodns-sync = octodns.cmds.sync:main     octodns-validate = octodns.cmds.validate:main 
like image 143
phd Avatar answered Sep 26 '22 16:09

phd