[setuptools] Install entry point only if extras_require are satisfied?
![](https://secure.gravatar.com/avatar/79bb1683332cae76c9132254eb4bb7f2.jpg?s=120&d=mm&r=g)
Hi, I'm modifying a python project which uses setuptools for installation. The project installs an entry point as such: setup_args["entry_points"] = { "console_scripts": ["w1thermsensor = w1thermsensor.cli:cli [CLI]"] } where [CLI] is a reference to an extra_requires entry. This entry looks like this: extras_require=dict(CLI="click>=7.0") With these two lines, the current behavior is that the w1thermsensor entry point is *always* installed when "setup.py install" is invoked, but the entry point will cause an error if its dependencies are not available. I would like to change the behavior, so that the entry point is *not installed* if the extra dependencies are not available (and perhaps also show a warning, indicating that this entry point has not been installed). How can I do this? Cheers, Jonatan
![](https://secure.gravatar.com/avatar/a3193139ea494c45e63752504f5ff1f2.jpg?s=120&d=mm&r=g)
On 2020 Feb 29, at 02:00, Jonatan Palsson <jonatan.p@gmail.com> wrote:
I would like to change the behavior, so that the entry point is *not installed* if the extra dependencies are not available (and perhaps also show a warning, indicating that this entry point has not been installed).
I don't believe this is possible. Achieving this new behavior would, at a minimum, require changes to pip (and possibly also to the entry points format in order to indicate which behavior is desired). As associating extras with entry points is currently considered deprecated to begin with, I doubt you'd have much luck convincing the pip maintainers to add such a feature. The closest way to get the behavior you want would be to split off the CLI-specific code from your project into a separate project, and have this new project install the entry point while always depending on the first project and the "CLI" extras. -- John Wodder
participants (2)
-
John Thorvald Wodder II
-
Jonatan Palsson