flit icon indicating copy to clipboard operation
flit copied to clipboard

Validate entry_points.txt on install, fail if necessary ?

Open Carreau opened this issue 7 years ago • 6 comments

A bad groupname can prevent other packages from starting as pkg_resources can raise raise ValueError("Invalid group name", group)

Carreau avatar Dec 28 '16 18:12 Carreau

I get the impression you hit this? What was the example? I think it makes sense to verify them when building the package.

On 28 Dec 2016 6:31 p.m., "Matthias Bussonnier" [email protected] wrote:

A bad groupname can prevent other packages from starting as pkg_resources can raise raise ValueError("Invalid group name", group)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/takluyver/flit/issues/96, or mute the thread https://github.com/notifications/unsubscribe-auth/AAUA9Qydn7xQcSl100bqoUorZNGh0iBBks5rMqr4gaJpZM4LXGrp .

takluyver avatar Dec 30 '16 12:12 takluyver

I get the impression you hit this? What was the example? I think it makes sense to verify them when building the package.

Yes, I did a package flitlicenses with an entrypoint group named [flit-licenses] (dash is invalid) and IPython was broken on startup (because pkg_resources scan and validate even non-IPython entrypoints...). Obviously I fixed it immediately and it was my fault, but I would still have prefered to be warned at install time with failure that later. And I was lucky enough to know from where it was coming.

Carreau avatar Dec 30 '16 14:12 Carreau

Flit now validates the object reference part of entry points (like flit:main), but it doesn't do anything with the group name. Do you know what rules pkg_resources checks it against?

takluyver avatar Dec 14 '17 14:12 takluyver

The errors seems to come from here: https://github.com/pypa/setuptools/blob/7f310da972ee9d979b8b0bfb9c19cabe91bf94a2/pkg_resources/init.py#L2410-L2413

The validator is here: https://github.com/pypa/setuptools/blob/7f310da972ee9d979b8b0bfb9c19cabe91bf94a2/pkg_resources/init.py#L2295

MODULE = re.compile(r"\w+(\.\w+)*$").match

(don’t know why github does not show snippets here)

merwok avatar Nov 11 '18 19:11 merwok

Thanks @merwok - PRs to validate the group names welcome.

takluyver avatar Nov 12 '18 16:11 takluyver

better to use the documented pkg_resources class function pkg_resources.EntryPoint.parse_group("group.name", []), instead of MODULE.

earonesty avatar Jan 06 '20 17:01 earonesty