Skip to content

pkg_resources hard-fails on install_requires for entry point. #1471

Closed
@pganssle

Description

@pganssle

This has bitten us a few times now, I think that pkg_resources is a bit aggressive about install_requires, so when you attempt to invoke an entry point, the install_requires list is checked, and if any of the dependencies are missing, the script fails to start.

This problem has come up because we have a system that side-loads pre-built source (a la DPKG and presumably other package managers) where the dependencies are declared by the package manager (so install_requires is actually mostly ignored at install time). Occasionally we have needed to change the name of the package deployed by the package manager even though the importable path has not changed. If someone has the old package name in their install_requires and invokes their script via python -m mypkg, it works fine, but if they are invoking through an entry point, the script fails to run because the dependencies are not installed.

To demonstrate, I have prepared a small repository that demonstrates this behavior.

This is a real problem because it occurs at runtime and there doesn't seem to be any obvious way to "shim" around it other than by providing a dummy package (with no easy way to notify users that they are relying on this dummy package).

I suggest changing the DistributionNotFound error into a warning instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs DiscussionIssues where the implementation still needs to be discussed.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions